K

Kanak Sharma • 5.38K Points
Tutor III

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

Explanation by: Kanak Sharma
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.


Question analytics