A

Admin • 833.24K Points
Coach

Q. What will be the output of the following C code?

Code:
#include <stdio.h>

void main()
{
int x = 10;
int y = x++ + 20;

printf("%d,%d",x,y);

return 0;
}
  • (A) 11,30
  • (B) 11,31
  • (C) 10,30
  • (D) 10,31
  • Correct Answer - Option(A)
  • Views: 19
  • Filed under category C Programming
  • Hashtags:

Explanation by: Admin

In the above code, we are using a post-increment statement (x++), post-increment increases the value after evaluating the current expression. Thus, the value of y will be 30 and then x will be 11.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.