What will be the output of the code?#includemain(){int a=10;int b;b=a++ + 20;printf("a= %d b= %d", a, b);}

The o/p will be 11 30. Can somebody tell me how?

Questions by vrijesh28

Showing Answers 1 - 9 of 9 Answers

Dan Dancescu

  • Oct 9th, 2007
 

The output is 11 30, because "++" is a postfix operator (applied after the operation) so the value that gets assigned to b is the initial value of a, which is 10, plus 20.

So b will be 30. Then a is incremented by 1, so a becomes 11.

Therefore this program prints out 11 30

jintojos

  • Jul 2nd, 2008
 

The variable a is incremented by one only after completing
the statement b=a++ + 20;
So after executing the statement b=a++ + 20 the variable b will have the value 30.
Then the value of variable a is incremented that is why the out put is 11 30.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions