0
What is wrong in it. Please explain
#include <iostream> using namespace std; int main() { int a ; int b ; int sum = a + b; cout <<"the sum of a+b is"; cin>>sum; cout << sum; return 0; }
4 Answers
+ 1
Cin means character input
Cout means character output
So you print "the sum of a+b" as a string then cin takes the value of sum and then cout prints the value of sum
+ 1
D_Stark, AJAY gurjar you may think of cin as character in, and cout as character out, but officially:
cin means console input
cout means console output
0
What is cin
0
You're adding a and b without assigning any values to them. Being local variables, they will contain unknown values. I presume you meant to use cin with a and b rather than sum.
E.g.
int a, b;
cin >> a >> b;
int sum = a + b;
cout << "the sum of a + b is " << sum;