0

{ int a = 100; a = 50; cout << a; return 0; } Why the output is 50 as the value of a is 100 & 50

17th Aug 2018, 7:50 AM
Manish kumar
Manish kumar - avatar
7 odpowiedzi
+ 4
The work is with these lines int a = 100; a =50 You first thing tell C++ to give "a" the value 100 The second line tells C++ to replace the former value of "a"(100) , with a new value (50)
17th Aug 2018, 8:42 AM
Dlite
Dlite - avatar
+ 3
the second value replace the first value... so 100 be 50
17th Aug 2018, 9:49 AM
Jingga Sona
Jingga Sona - avatar
+ 2
but what did you expect to change the initial value of 100 to 50? Variables can not store multiple values ​​if they are neither structures, nor classes, nor unions
17th Aug 2018, 7:59 AM
Roman Khristoforov
Roman Khristoforov - avatar
0
they are right
25th Aug 2018, 11:40 PM
Jktu 1ord
Jktu 1ord - avatar
0
ahhh c++ :-)
25th Aug 2018, 11:45 PM
Женя
Женя - avatar
0
As after intializing the value of a to 100 its value is changed to 50
30th Aug 2018, 8:37 AM
sanskar kumar
0
the program changed the output to 50 becsause u told it to :) u changed the value from 100 to 50
2nd Sep 2018, 4:25 PM
HluBiic
HluBiic - avatar