+ 1

++A + ++A=?

if we take A=0 initially . I get the output as 4 in code::blocks see the program:- #include<studio.h> void main() { int a=0,b; b=++a + ++a; printf("%d", b); }

23rd Feb 2017, 11:14 AM
Rohit Kumar
Rohit Kumar - avatar
7 Réponses
+ 5
I presume you executed this code in C++, where both increments are done first. So, 'A' becomes 2 and the result is 2 + 2 which is 4 in C++. In JavaScript, 1 + 2 which is 3 will be the result.
23rd Feb 2017, 11:43 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 3
try again save with .c
5th Mar 2017, 3:40 PM
Yash Gohel
Yash Gohel - avatar
+ 2
3
23rd Feb 2017, 11:35 AM
Yash Gohel
Yash Gohel - avatar
+ 2
Yes it would be 4
6th Mar 2017, 9:36 AM
Ravindra Sisodia
Ravindra Sisodia - avatar
+ 1
actually result is 4 how it possible
23rd Feb 2017, 6:03 PM
meherDev
meherDev - avatar
0
but Yash, I got 4 when I run the program!!
23rd Feb 2017, 11:38 AM
Rohit Kumar
Rohit Kumar - avatar
0
in Turbo, it gives 3!!😐🤔
23rd Feb 2017, 11:45 AM
Rohit Kumar
Rohit Kumar - avatar