ProgrammingModerate
int n = 3; int *p = &n; printf("%d", *p * *p + *p); What is printed?
- A. 9
- B. 15
- C. 12
- D. 6
Correct answer: C. 12
The expression is 3 * 3 + 3 = 12, with both dereferences giving n.
More C Programming questions
- int m[2][2] = {{1, 2}, {3, 4}}; int p = &m[0][0]; printf("%d", p[2] p[1]); What is printed?
- unsigned char c = 255; c++; printf("%d", c); What is printed?
- int i = 0; printf("%d %d", i++, i); What does this code do?
- const char names[] = {"zero", "one", "two"}; printf("%c", names[2][1]); What is printed?
- int x = 0; for (int i = 0; i < 4; i++) x += i % 2 ? i : -i; printf("%d", x); What is printed?
- int x = 10; int p = &x; p += p 2; printf("%d", x); What is printed?