1 Replies - 328 Views - Last Post: 11 August 2009 - 03:20 AM Rate Topic: -----

#1 jebastino  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-July 09

need to include a function module into the main program by using func

Post icon  Posted 11 August 2009 - 03:13 AM

plz help me
#include<iostream.h>
 #include<conio.h> 
#include<stdlib.h>
 #include<math.h> void main()
 { int a,ans,guess; char s; int i=1;
 clrscr(); 
do { ans=multiply(); 
cout<<" \n can u guess the answer"; 
cin>> guess;
 if(ans==guess) 
cout<<"excellent!! \n Keep it up ";
 if (ans!=guess) 
do { cout<<" \n u can guess"<<"\n this is\t"<<i<<" \tchance for u";
 cin>> guess; 
if(ans!=guess) cout<<"\n ohhhhhh soorrryyyy";
	 i++; 
}while(i<=5);
 cout<<"\n the answer is "<<ans;
 getch();
 cout<<"\n would u like to continue...\n if Yes means press y \n press any key to quit the game"; cin>>s; }while(s=='y'); 
}
int multiply()
 { int multiplicand,multiplier,result;
 randomize(); 
multiplicand=1+random(9);
 multiplier=1+random(9); 
result = multiplicand*multiplier;
 cout<<"\n the"<<multiplicand<<" times"<<multiplier<<"is __________"; return result; }

in this program the function "multiply" used inside the main program.
i need to include the function as a header file.
help me
please

Is This A Good Question/Topic? 0
  • +

Replies To: need to include a function module into the main program by using func

#2 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,898
  • Joined: 25-October 06

Re: need to include a function module into the main program by using func

Posted 11 August 2009 - 03:20 AM

View Postjebastino, on 11 Aug, 2009 - 09:13 AM, said:

plz help me

in this program the function "multiply" used inside the main program.
i need to include the function as a header file.
help me
please

multiply() is in the file so you just need a function prototype before main(), e.g.
#include<iostream.h>
 #include<conio.h>
#include<stdlib.h>
 #include<math.h>

int multiply();		// function prototype

int main()
{


however, randomize() and random() are then missing
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1