Tuesday 2 September 2008

Array of pointer questions with solution

(5) What will be output ?
Ans:
#include
#include
unsigned long int (* avg())[3]
{
static unsigned long int arr[3]={1,2,3};
return &arr;
}
void main()
{
unsigned long int (*ptr)[3];
ptr=avg();
clrscr();
printf("%d",*(*ptr+2));
getch();
}
Output :3
(6) What will be output ?

#include
#include
void main()
{
char arr[5]={1,2,3,4,5};
char (*ptr)[5];
ptr=&arr;
ptr=(*ptr)+2;
clrscr();
printf("%d",**ptr)

No comments:

Post a Comment