Can someone check whts wrong with my program | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone check whts wrong with my program

https://code.sololearn.com/ci7T581tbBBk/?ref=app

9th Mar 2018, 2:53 AM
Hacker 815
2 Answers
+ 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; }
9th Mar 2018, 2:55 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
0
Tnx
9th Mar 2018, 3:02 AM
Hacker 815