+ 1
Why output is 12?
#include<stdio.h> int main() { int a,b=5; a=++b; printf("%d",a+b); return 0; }
5 Antworten
+ 8
Well b=5. Alright then a=++b. This will first increment b (b=b+1) which will make it equal to 6, then it will assign its value to a (so a=b=6).
Therefore, a+b=6+6=12
I hope it's clear...
+ 7
You're welcome Kawser I'm glad I could help 👍👍
+ 2
a = 0, b = 5
a = 6 (since a = ++b) now b = 6 (since ++b)
a+b = 6 + 6 = 12
printing we have 12
++b increment the value of b first before used.
a = ++b in this case the increment value would be assigned to a.
b++ first used then the value is incremented.
a = b++ in this case the value of b is assigned to a without incrementing and then b is incremented.
+ 1
thanks to all.its clear now