Value b | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Value b

When I just wrote only 1 number(ex: 34), output screen showed me result "34 8". I don't know number 8 why appearing on output #include <iostream> using namespace std; int main() { int a, b; cout << "Enter a number \n"; cin >> a; cout << "Enter another number \n"; cin >> b; return 0; }

25th May 2019, 2:22 AM
Hiep Do Hoang
Hiep Do Hoang - avatar
5 Answers
+ 3
If you mean that you only input one number, then the variable b would be a "garbage number", which the value depends on compiler.
25th May 2019, 2:59 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
Not exactly right. It might be 8 on your compiler, but 204306 on my compiler. The default is not 8 but depends on the compiler. SoloLearn playground shows the value of b is 8, but not in my compiler.
25th May 2019, 3:09 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 1
yes yes
25th May 2019, 3:01 AM
Hiep Do Hoang
Hiep Do Hoang - avatar
+ 1
Thanks a lot. I understand that CarrieForle
27th May 2019, 4:40 AM
Hiep Do Hoang
Hiep Do Hoang - avatar
0
it means that value b is 8 or base on complier
25th May 2019, 3:04 AM
Hiep Do Hoang
Hiep Do Hoang - avatar