ProgrammingModerateAccenture · Cognizant pattern
What is printed?
What is printed?
int x = 10;
int *p = &x;
int **q = &p;
**q = 20;
printf("%d", x);- A. 10
- B. 20
- C. The address of x
- D. Compilation error
Correct answer: B. 20
q points to p, and p points to x, so **q is x itself. Assigning 20 through **q changes x to 20.
More C Programming questions
- What is printed? c char s[20] = "Code"; strcat(s, "Hub"); printf("%zu", strlen(s));
- What is printed on a two's-complement machine? c printf("%d", ~5);
- What is printed by a C99 (or later) compiler? c printf("%d %d", -7 / 2, -7 % 2);
- What is printed? c char s = "Campus"; printf("%c%s", (s + 1), s + 4);
- What is printed? c printf("%d", printf("hello"));
- On a 64-bit system (8-byte pointers, 4-byte int), what does f print? c void f(int a[10]) { printf("%zu", sizeof(a)); }