+ 2
Please tell me guys how to work pre-increment operator and tell me how to come here 15,66 result.
#include <studio.h> int main() { int a,b; a=10; b=(++a)+(++a)+(++a)+(++a)+(++a); printf ("A nd B is=%d %d",a,b); return 0; }
7 Antworten
+ 1
how "b" become 66
0
actually it should be 15,65 in my opinion.
you have a=10 in start, but every ++a operation increments it’s value to one integer more, so ++a equal 11, next +a equal 12 and finally, because you have did this operation five times, your a equals 15.
incouding this knowing, you will be count b as 11+12+13+14+15 (because every ++a opeartion is returning a as one integer higher value). so now b equals 65 (because in the start you didn’t set this value, so it was zero).
notation „%d” takes the next argument and prints it as a int. so a and b will be print as a int.
now you get 15,65
0
yes you are right but when we run this code then come the output is 15,66.
0
yes 15 ,66 is right answer because when use ++a oprator for addition it get 1 plus in answer
0
but why
- 1
please explain me
- 1
салом