0
Can someone check whts wrong with my program
2 Antworten
+ 4
You need to assign sum after you get the values of a and b, or you will get a garbage value, as a and b don't have any values till the cin>> operation.
Thus, the code will be:
#include <iostream>
using namespace std;
int main()
{
int a, b;
cout << "Please enter 2 numbers \n";
cin >> a >> b ;
int sum=a+b;
cout << sum ;
return 0;
}
0
Tnx