0 0 votes What will be the output of the following $\text{C}$ code?#include<stdio.h> void main() { int arr[5]={10,20,30,40,50}; int *p = (int*) (&arr+1); printf("\%d\%d", *(arr + 1), *(p -1)); } $10$ $50$$20$ $50$$30$ $40$$20$ $40$ Programming in C ugcnetcse-aug2024 programming-in-c array pointers output + – Shubham Sharma 2 257 views answer comment Share Follow Print See 1 comment 1 1 comment reply Vishnu__ commented Jan 21 reply Follow flag 20 50correct me if any ;) 0 0 replyShare Please log in or register to add a comment.
0 0 votes int arr[5]={10,20,30,40,50}; //for suppose base address is 1000 then address of arr+4 (last element in the array) is 1016.Assuming int=4B.int *p = (int*) (&arr+1);&arr represents address of whole array,so &arr+1 =1000+size(&arr)=1020.p=1020.And "arr" represents first element address which is 1000.In the printf statement *(arr + 1)=*(1000+sizeof(int))=*(1004)=second element in the array=20And *(p-1)=(1020-size(int))=*(1016)=last element in the array=50.The Output is 20 50 krishnalohithitla answered Jun 26 krishnalohithitla comment Share Follow 0 reply Please log in or register to add a comment.