ProgrammingModerateAccenture · Cognizant
What is printed?
What is printed?
int x = 10;
int *p = &x, **pp = &p;
printf("%d", **pp + *p * 2);- A. 30
- B. 20
- C. 40
- D. 12
Correct answer: A. 30
**pp and *p both reach x = 10. * (multiplication) binds tighter than +, so the value is 10 + 10 × 2 = 30. '40' adds before multiplying.
More C Programming questions
- What is printed? c const char s = " 42, 17"; printf("%zu %zu", strspn(s, " "), strcspn(s, ","));
- A header config.h is wrapped as #ifndef CONFIGH / #define CONFIGH / … / #endif. What problem does this prevent?
- With 4-byte int, after these lines run, which block can no longer be freed because no pointer to it remains? c int a = malloc(10…
- What is printed? c int pal(const char s, int i, int j) { if (i >= j) return 1; if (s[i] != s[j]) return 0; return pal(s, i + 1, j - 1); }…
- With 4-byte int, what is printed? c typedef int Row[3]; Row m[2] = {{1, 2, 3}, {4, 5, 6}}; Row p = m; printf("%zu %d", sizeof(Row)…
- What is printed? c int a = 0, b = 0, c = 0; if ((a = 2) && (b = 0) || (c = 3)) a++; printf("%d %d %d", a, b, c);