ProgrammingModerateTCS NQT · Infosys pattern
What is printed?
What is printed?
printf("%d", 10 / 3 * 3);- A. 10
- B. 1
- C. 9
- D. 3
Correct answer: C. 9
/ and * have equal precedence and group left to right: 10 / 3 = 3 (integer division drops the fraction), then 3 × 3 = 9. Getting 10 means treating it as real division.
More C Programming questions
- What is printed? c int a = 5, b; b = a++ + 10; printf("%d %d", a, b);
- What is printed? c char s[] = "placement"; printf("%zu %zu", sizeof(s), strlen(s));
- What is printed? c int arr[] = {10, 20, 30, 40}; int p = arr; p += 2; printf("%d", p);
- What does f(4096) return? c int f(int n) { if (n == 0) return 0; return n % 10 + f(n / 10); }
- What is printed? c printf("%d %d %d", 12 & 10, 12 | 10, 12 ^ 10);
- What is printed? c #define SQUARE(x) x x printf("%d", SQUARE(2 + 3));