Question discussion

What is the output of the code written in C?

359805Medium DSSSB TGT Computer Science 0 replies 0 views
0

What is the output of the code written in C?

void main()
{
    printf("%d", 7 % -3);
    printf("%d", -7 % 3);
}
  • A1 1
  • B-1 -1
  • C-1 1
  • D1 -1
Correct answer: D

Explanation

In C, the sign of the remainder follows the dividend. 7 % −3 = 1 and −7 % 3 = −1, so the output is "1 -1".

Discussion 0

Nobody has replied yet. Start the discussion!