Cannot understand output for the following code!!please explain!!(in GCC compiler) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Cannot understand output for the following code!!please explain!!(in GCC compiler)

#include<stdio.h> int main() { int a=10,b; b=a++ + ++a; printf("%d,%d,%d,%d",b,a++,a,++a); }

11th Jun 2017, 12:07 PM
Vijaysai Suri
Vijaysai Suri - avatar
2 Answers
+ 1
a=10 b = a++ + ++a b gets the value of a(10) + a+1(12) = 22 a increments after it's use (11), then a increments before its use (12) The output is 22,12,13,14 print b, then print a and increments it, then print a(incremented, 13) then increments a before it's use so print 14
11th Jun 2017, 12:16 PM
Andrés04_ve
Andrés04_ve - avatar
0
tq..but when i compiled here( http://rextester.com/l/c_online_compiler_gcc) ..it shows different answer ..it gives 22,13,14,14..please help:)
11th Jun 2017, 12:31 PM
Vijaysai Suri
Vijaysai Suri - avatar