PDA

View Full Version : Code Problem



Unknown
01-28-2004, 04:34 AM
I was messing around trying to make a code and i did this simple multipcation code:



#include <iostream.h>

int multiply()
{

int number1;
int number2;
int multiplydone;
cout<<"Type the first number:\n";
cin>>number1;
cout<<"Type the second number:\n";
cin>>number2;
multiplydone = number1 * number2;
return multiplydone;
}
int main()
{
int answer;
answer = multiply();
cout<<"The answer is:"<<answer;
system("PAUSE")
return 0;
}



can somsone tell me whats wrong if any thing is wrong?

Spookster
01-28-2004, 06:19 AM
If you don't know if anything is wrong then why are you asking a question about it? You need to tell us what the problem is.

mesbaba8
01-28-2004, 10:25 AM
#include <iostream.h>


int multiply(void);
int multiply(void)
{

int number1;
int number2;
int multiplydone;
cout<<"Type the first number:\n";
cin>>number1;
cout<<"Type the second number:\n";
cin>>number2;
multiplydone = number1 * number2;
return multiplydone;
}
int main()
{
int answer;
answer = multiply();
cout<<"The answer is:"<<answer;
system("PAUSE")
return 0;
}


i donno c++ but you have to add the bold line in C

dragon
01-28-2004, 01:15 PM
That shouldn't be necessary for C++.

By the way, Unknown, why don't you just compile the code and see if there are any problems? Although I believe you're missing a semi-colon in the main().

Unknown
01-28-2004, 01:25 PM
Thx dragon it was the semi colon :) I hate those.

Mhtml
01-28-2004, 01:52 PM
On system() again? Hehe, I picked up that mistake last time! ;)

Unknown
01-28-2004, 05:06 PM
Ya :) I made sure that i put it the first time I compiled it. But when I took out the system() and put it back in i forgot to put the ;

oracleguy
01-28-2004, 05:54 PM
Make sure you read our posting guidelines (http://www.codingforums.com/postguide.htm) before you start new thread so you can properly name it. "Code Problem" doesn't say much considering the his a development help forum.

Unknown
01-28-2004, 10:03 PM
There isnt a forum that says C++. So I resolved to this since its the closest thing.

liorean
01-28-2004, 10:08 PM
Well, that wasn't the thing he objected to. This is the correct forum to ask such questions in. The thing he objected to was the title you gave your post.