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

explain memory layout of a C program

2 Answers  


What is structure of c program?

0 Answers  


Write a program to enter the name and age. If age>28 then find salary categories. if age<28 then find that you are gaduate or not.

1 Answers  


Why do we use header files in c?

0 Answers  


What is exit() function?

0 Answers  


logic for x=y^n

1 Answers   Delphi,


What are the storage classes in C?

0 Answers  


Is it possible to have a function as a parameter in another function?

0 Answers  


Write a program to generate the first n terms in the series --- 9,11,20,31,...,82

1 Answers   Cognizant,


An array name contains base address of the array. Can we change the base address of the array?

4 Answers   NMIMS, Wipro,


how to write a cprogram yo get output in the form * *** ***** ******* ********* ******* ***** *** *

3 Answers  


How can I access a memory located at certain address?

2 Answers   CSC,


Categories