7th Feb 2018, 2:25 AM
GO!
GO! - avatar
6 ответов
+ 13
You should not add a and b to d before cin. int a,b, d; cin >> a >> b; d = a + b; cout << d;
7th Feb 2018, 2:27 AM
Hatsy Rei
Hatsy Rei - avatar
+ 7
We want to take user input, and then add the two numbers, not the other way around.
10th Feb 2018, 1:03 PM
Hatsy Rei
Hatsy Rei - avatar
+ 7
Exactly. Check on what garbage values in uninitialised variables are: https://www.quora.com/What-do-you-mean-by-a-garbage-value-in-a-variable
11th Feb 2018, 12:23 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
thank you very much! 😀Hatsy Rei
12th Feb 2018, 4:36 AM
GO!
GO! - avatar
+ 1
I have a idea! (when "d=a+b is before cin) Is it becuz at that moment, variable a and variable b have no value?So the value of variable d become something weird.No help if I assign a and b some value. Am I right?
10th Feb 2018, 11:11 PM
GO!
GO! - avatar
0
Is it the format? or there is other explanation?
7th Feb 2018, 1:37 PM
GO!
GO! - avatar