C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 5)
What will be the output of the program If the integer is 4bytes long?

int main()
    int ***r, **q, *p, i=8;
    p = &i;
    q = &p;
    r = &q;
    printf("%d, %d, %d\n", *p, **q, ***r);
    return 0;
8, 8, 8
4000, 4002, 4004
4000, 4004, 4008
4000, 4008, 4016
Answer: Option
No answer description is available. Let's discuss.
35 comments Page 1 of 4.

Reddy Royal said:   4 years ago
Thanks @Kiran Kumar.

Niya said:   4 years ago
Right, thanks @Shubham Patil.

Shubham Patil said:   4 years ago
Here i = 8.

1) As p=&i is representing the value of i is 8.

2) q=&p => stores the address of p.
*q is the address stored in q ie address of p.
**q = value at address at p i.e. 8.

3) r=&q
Therefore *r= address of q.
**r= *(*q).
***r= *(*(*q)).
That i the value stored in p = 8.

Hence the answer is 8 8 8.

Divya said:   6 years ago
Thanks @Sunil Pradhan.

Prajakta said:   6 years ago
Thank you very much @Sunil pradhan.

Preethi said:   7 years ago
Thank you @Keerthi. Nice explanation.

Sujata said:   7 years ago
@Sunil Pradhan.

Well explained, thanks!

Shivani agrawal said:   7 years ago
p=&i implies *p=8;
q=&p implies *q=p means **q=8;
r=&q implies *r=q means ***r=8;
So, *p=**q=***r=i=8;.

Sujit said:   7 years ago

The Explanation is perfect. Thanks.

SONY said:   7 years ago
Thank you all for providing very good explanations.

Post your comments here:

Your comments will be displayed after verification.