+ 9
Not getting the desired output in the result.
This is the code, but I cannot find that mistake. #include <iostream> using namespace std; int main () { int a, b; int sum; cout << "Enter a number \n"; cin >> a; cout << "Enter another number \n"; cin >> b; sum = a + b; cout << "sum is: " sum << endl; return 0; }
10 Answers
+ 4
Jet ^_^ đźđł Akib Reza a simple mistake by both of you. đ
Jet has cout << "sum is: " sum << endl;
Akib has cout << "sum is: << sum << endl;
Correct is cout << "sum is: " << sum << endl;
+ 7
Akib Reza Even those are also not working,
+ 7
Andre Daniel It worked, thanks a lot,đ
+ 6
https://code.sololearn.com/c8FwTlgf3n9h/?ref=app
This is the code Andre Daniel
+ 2
cout << "sum is : "<< sum<< endl;
also using float for adding values is better if you wanna add decimal points.
+ 2
I didn't ask you to copy what i wrote and paste it. It was just the syntax. Didn't check it I was in a bit hurry.
Yes it was a typo thanks for correcting it.
+ 1
Can you put the code in the sololearn playground and send the link? That way it's easier for us to find the problem and possible solution.
+ 1
ypu must add <iostream.h>
+ 1
#include <iostream>
using namespace std;
int main ()
{
int a, b;
int sum;
cout << "Enter a number \n";
cin >> a;
cout << "Enter another number \n";
cin >> b;
sum = a + b;
cout << "sum is: " << sum << endl;
return 0;
}
+ 1
you forgot the cin.get(); and cin.ignore()