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
πŸ’¬ Discuss
βœ… Correct Answer: (A) 11,30
Explanation: 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.
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.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
334
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Kanak Sharma
Publisher
πŸ“ˆ
95%
Success Rate