top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What will be output if you will execute following C code?

+3 votes
221 views
#include<stdio.h>

int main(){ 
 int s=2,*r=&s,**q=&r,***p=&q;

 printf("%d",p[0][0][0]);
 return 0;
}

Please provide the explanation of the answer also.

posted May 22, 2015 by Mohammed Hussain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

Output: 2

Explanation:

As we know p[i] =*(p+i)
So,
P[0][0][0]=*(p[0][0]+0)=**p[0]=***p
Another rule is: *&i=i
So,
***p=*** (&q) =**q=** (&r) =*r=*(&s) =s=2
answer May 25, 2015 by Manikandan J
...