what would be the output of the following program

main()
{
int a[] = {1,2,3,4,5};
int *ptr = {a,a+1,a+2,a+3,a+4};
printf("%d %d %d %d",a,*ptr,**ptr,ptr);
}

}



what would be the output of the following program main() { int a[] = {1,2,3,4,5}; int *ptr =..

Answer / vadivelt

Output:

1.Base address of 'a'
2.Base address of 'a' (Since ptr holds address of the array 'a')
3.Value at the base address of 'a' ie., 1
4.Base address of array of pointers ie., address of 'ptr'

The above answer is valid provided the initialisation of *ptr
should be a array of pointers.

ie., initialisation should be int *ptr[]=
{a,a+1,a+2,a+3,a+4};

Otherwise it leads to compilation error

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Why are all header files not declared in every c program?

0 Answers  


write a program to find lcm and hcf of two numbers??

1 Answers  


Can a variable be both constant and volatile?

0 Answers  


Is c is a low level language?

0 Answers  


What is page thrashing?

0 Answers  






What is C language Terminator?

15 Answers   TCS,


Is there sort function in c?

0 Answers  


What is the purpose of Scanf Print, getchar, putchar, function?

3 Answers  


write a c program for print your name .but,your name may be small letter mean print a capital letter or your name may be capital letter mean print a small letter .example \\enter ur name : sankar The name is: SANKAR (or) enter your name:SAnkar The name is:saNKAR

5 Answers  


What is Function Pointer? Explain with example?

3 Answers  


write a c program to calculate sum of digits till it reduces to a single digit using recursion

0 Answers   IBM,


is forign key will be unique key any table or not?

2 Answers  


Categories