Question discussion

What is the output of the following C program?#include int main() { int x = 10, *p = &x, **q = &p; **q += 5; *p *= 2; printf("%d %d", x, **…

1553Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following C program?

#include <stdio.h>
int main() {
    int x = 10, *p = &x, **q = &p;
    **q += 5;
    *p *= 2;
    printf("%d %d", x, **q);
    return 0;
}
  • A15 15
  • B20 20
  • C30 15
  • D30 30
Correct answer: D

Explanation

**q += 5 makes x = 15 and *p *= 2 makes x = 30; both x and **q refer to the same variable.

Discussion 0

Nobody has replied yet. Start the discussion!