A

Admin • 833K Points
Coach

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

Code:
#include <stdio.h>

int main()
{
int x = 20;
x %= 3;
printf("%d",x);

return 0;
}
  • (A) 2
  • (B) 2.5
  • (C) Error
  • (D) Warning
  • Correct Answer - Option(A)
  • Views: 23
  • Filed under category C Programming
  • Hashtags:

Explanation by: Admin

In the above code, the value of x is 20 and then in the next statement, the expression is x %= 3. That will be evaluate as:

x %= 3;
x = x % 3;
x = 20 %3;
x = 2

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.