Question discussion

What is the output of the code written in C?

360018Medium DSSSB TGT Computer Science 0 replies 0 views
0

What is the output of the code written in C?

void main()
{
    int k = 8, v = 8, i;
    i = k / ++v;
    printf("%d\n", i);
}
  • A0
  • B1
  • C0.8
  • DError
Correct answer: A

Explanation

++v makes v = 9, so i = 8 / 9. Integer division gives 0, so the program prints 0.

Discussion 0

Nobody has replied yet. Start the discussion!