Question 14Asked in DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2

What is the output of the code written in C? void main()

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); }
  1. A0
  2. B1
  3. C0.8
  4. DError
Show answerHide answer

Correct answer: (A) 0

Explanation

++v makes v = 9 before the division. Then i = 8/9 = 0 because integer division drops the fraction. printf prints 0 (followed by the literal text "/n").

From DSSSB TGT Computer Science PYQ (Technical), 8 Aug 2021, Shift 2

This is question 14 of DSSSB TGT Computer Science PYQ (Technical), 8 Aug 2021, Shift 2. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.