Question discussion

What is the output of the code written in C?

358617Medium 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);
}
  • AError
  • B1
  • C0
  • D0.8
Correct answer: C

Explanation

The pre-increment makes v = 9 before the division. Then i = 8 / 9, which is integer division and gives 0, so the program prints 0.

Discussion 0

Nobody has replied yet. Start the discussion!