#include#includevoid main(){static int a[]={0,1,2,3,4};clrscr();int *p[]={a,a+1,a+2,a+3,a+4};printf("n%un%un%d",p,*p,*(*p));getch();}What will be the output of above program?How?

Questions by saurabh08_chd

Showing Answers 1 - 2 of 2 Answers

Swati H. Sanu

  • Oct 15th, 2007
 

p is the adress of a and *p is value at address a[0] and *(*p) is again address of a

  Was this answer useful?  Yes

coolquasar

  • Sep 15th, 2008
 

It works like this

Address of a[0] = a

a[0] = 0 (<--1000 Address)

a[1] = 1 (<--1004 Address)

a[2] = 2 (<-- 1008 Address)

a[3] = 3 (<-- 1012 Address)

a[4] = 4 (<-- 1016 Address)

Address of p[0] = p

p[0] = 1000 (<-- 2000 Address) 1000 is the address of a[0] (a)

p[1] = 1004 (<-- 2004 Address) 1004 is the address of a[1] (a+1)

p[2] = 1008 (<-- 2008 Address) 1008 is the address of a[2] (a+2)

p[3] = 1012 (<-- 2012 Address) 1012 is the address of a[3] (a+3)

p[4] = 1016 (<-- 2016 Address) 1016 is the address of a[4] (a+4)

For printf("**%u**%u**%d",p, *p, *(*p));

the output should look somethin like this

**2000**1000**0

 

 

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions