C Programming · Question 27 · Hard

What will be the output of the following C program?

#include <stdio.h>

int main(void) {
    int a = 10;
    int *p = &a;
    int **q = &p;
    **q += 5;
    *p *= 2;
    printf("%d", a);
    return 0;
}
  1. 25
  2. 20
  3. 15
  4. 30
Answer and explanation

Answer: D. 30

Explanation: **q and *p both refer to a. **q += 5 makes a 15, then *p *= 2 makes it 30.

Previous: What will be the output of the following C program? · Next: What will be the output of the following C program?

Practise c programming

Try a fresh set of c programming questions with an explanation after every answer, free and without signing up: C Programming practice. Or sit a full placement mock test.

More c programming questions

More technical & programming practice

Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge