What did I do wrong?
Mar 28, 2012 at 10:21pm UTC
Can some one please help? What is wrong here?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#include <iostream>
using namespace std;
int main()
{
int num1;
int num2;
int answer3;
cout << "Enter first number:" << endl;
cin >> num1 >> endl;
cout << "Enter second number:" << endl;
cin >> num2 >> endl;
answer3 = num1 * num2;
cout << "Here's the answer" << answer3 << endl;
system ("PAUSE" );
return 0;
}
Mar 28, 2012 at 10:32pm UTC
First of all use
cin.get();
instead of
system("PAUSE" )
for many reasons. and for the errors you cant use endl with cin. you have to be using cout for endl and these have to be before it <<.
heres the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#include <iostream>
using namespace std;
int main()
{
int num1;
int num2;
int answer3;
cout << "Enter first number:" << endl;
cin >> num1;
cout << "Enter second number:" << endl;
cin >> num2;
cout << endl;
answer3 = num1 * num2;
cout << "Here's the answer" << answer3 << endl;
cin.get();
return 0;
}
Mar 28, 2012 at 10:33pm UTC
I think that the problem is in the statement
cin >> num1 >> endl;
endl - is a function.
You should write simply
cin >> num1;
Last edited on Mar 28, 2012 at 10:33pm UTC
Mar 28, 2012 at 10:39pm UTC
cin >> num1 >> endl ;
you don't need this but if you want to make the Indicator goes to another line
you can make like this.
1 2 3 4 5 6 7 8
cout << "Enter first number: " ;
cin >> num1;
cout << endl;
cout << "Enter second number: " ;
cin >> num2;
cout << endl;
cout << "Here's the answer " << answer3 << endl;
try this
Topic archived. No new replies allowed.