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

What are the phases in s/w developed life cycle? wat is the diff b/w stack & queue...where do we use stack

6 Answers  


Difference between C and Embedded C?

1 Answers  


Write a program to compute the following 1!+2!+...n!

4 Answers  


Is array a primitive data type in c?

1 Answers  


Explain the concept and use of type void.

1 Answers  


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

1 Answers  


Why is the code below functioning. According to me it MUST NOT.

1 Answers  


How can you draw circles in C?

1 Answers   Accenture,


who is the father of c

4 Answers   Infosys,


How can I avoid the abort, retry, fail messages?

1 Answers  


Is null always equal to 0(zero)?

1 Answers  


write a code for large nos multilication (upto 200 digits)

2 Answers   Persistent,


Categories