ProgrammingHardTCS NQT · Infosys

double x = 7 / 2 * 2.0; printf("%g", x); What is printed?

  1. A. 6
  2. B. 7
  3. C. 3.5
  4. D. 3

Correct answer: A. 6

7 / 2 is integer division and gives 3 before the multiplication by 2.0. The result 6.0 prints as 6 with %g.

More C Programming questions

Exams that ask this topic