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

? ???Mirror Mirror on the wall????????

1 Answers   channel V, DPI,


What are c preprocessors?

0 Answers  


What happens if you free a pointer twice?

0 Answers  


Explain what are multidimensional arrays?

0 Answers  


Can a binary search tree be used as an index? If yes, how? Explain

0 Answers   TCS,






How to implement a packet in C

0 Answers   Aricent,


2. Counting in Lojban, an artificial language developed over the last fourty years, is easier than in most languages The numbers from zero to nine are: 0 no 1 pa 2 re 3 ci 4 vo 5 mk 6 xa 7 ze 8 bi 9 so Larger numbers are created by gluing the digit togather. For Examle 123 is pareci Write a program that reads in a lojban string(representing a no less than or equal to 1,000,000) and output it in numbers.

3 Answers   Nagarro,


how to create c progarm without void main()?

1 Answers   NIIT,


#include<stdio.h> void main() { int a,b,c; a=b=c=1; c=++a || ++b && ++c; printf("%d\t%d\t%d",a,b,c); }

3 Answers  


how would a 4*3 array A[4][3] stored in Row Major Order?

0 Answers   HCL, Ignou,


Q-1: Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college.

8 Answers  


Which are low level languages?

0 Answers  


Categories