C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 5)
5.
What will be the output of the program If the integer is 4bytes long?
#include<stdio.h>
int main()
{
int ***r, **q, *p, i=8;
p = &i;
q = &p;
r = &q;
printf("%d, %d, %d\n", *p, **q, ***r);
return 0;
}
Discussion:
35 comments Page 4 of 4.
Prajakta said:
7 years ago
Thank you very much @Sunil pradhan.
(1)
Divya said:
7 years ago
Thanks @Sunil Pradhan.
(2)
Shubham Patil said:
6 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.
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.
(5)
Niya said:
5 years ago
Right, thanks @Shubham Patil.
Reddy Royal said:
5 years ago
Thanks @Kiran Kumar.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers