πŸ“Š C Programming
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
πŸ’¬ Discuss
βœ… Correct Answer: (A) 2

Explanation: 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

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

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
386
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Kanak Sharma
Publisher
πŸ“ˆ
89%
Success Rate