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); getch(); } Output: 3 (8) void main() { char *arr[3]; char a=1,b=2,c=3; arr[0]=&a; arr[1]=&b; arr[2]=&c; clrscr(); printf("%u %u",&b,arr[1]); printf("\n%d",*arr[2]); getch(); } Output : 6678(any addresss) 6678(same address) 3
Post a Comment