ProgrammingHardTCS NQT · Infosys
double x = 7 / 2 * 2.0; printf("%g", x); What is printed?
- A. 6
- B. 7
- C. 3.5
- 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
- unsigned char c = 0x0F; printf("%d", (unsigned char)~c); What is printed?
- int i = 0; if (0 && i++) ; if (1 || i++) ; printf("%d", i); What is printed?
- unsigned char a = 255; printf("%d", a == -1); What is printed?
- long long x = 1000000LL 1000000; What is x?
- What does printf("%d", sizeof('a') == sizeof(int)) print?
- char words[] = {"one", "two", "three"}; char pp = words + 1; printf("%s", pp + 1); What is printed?