14 votes 14 votes Consider the following C program: #include <stdio.h> int main() { int arr[]={1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 5}, *ip=arr+4; printf(“%d\n”, ip[1]); return 0; } The number that will be displayed on execution of the program is _______ Programming in C gatecse-2019 numerical-answers programming-in-c programming array easy 1-mark + – Arjun asked Feb 7, 2019 • retagged Dec 26, 2023 by Hira Thakur Arjun 13.6k views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply Ashwani Kumar 2 commented Jun 3, 2019 reply Follow Share arr is base address of element $1$. arr+$4$ is base address of element $5$. Let it ip. ip[$1$]=*(ip+$1$)= Base address of element $6$. 6 is the answer. 2 votes 2 votes subbus commented Apr 27, 2020 reply Follow Share *p = arr + 4 = arr[4] *(p+0) = arr[4] *(p+1) = arr[4+1] = arr[5] 0 votes 0 votes mahendrapatel commented Jan 23, 2023 reply Follow Share Easy 0 votes 0 votes himanshud2611 commented Jan 28 reply Follow Share ip[1] is *(ip+1) i.e 6 0 votes 0 votes Please log in or register to add a comment.
Best answer 26 votes 26 votes $6$ ip is an integer pointer and the initial assignment sets it to the element at array index $4$ i.e. $5$.(holds address of ar index $4$) The next statement refers to the next integer after it which is $6 (ip[1]=*(ip+1))$. vin101 answered Feb 7, 2019 • edited Apr 28, 2019 by go_editor vin101 comment Share Follow See 1 comment See all 1 1 comment reply neel19 commented Jun 13, 2020 reply Follow Share The dereferencing part made it clear. 0 votes 0 votes Please log in or register to add a comment.
16 votes 16 votes Hence Ans is 6. Rajesh Pradhan answered Feb 7, 2019 Rajesh Pradhan comment Share Follow See all 0 reply Please log in or register to add a comment.
8 votes 8 votes int arr[]={1,2,3,4,5,6,7,8,9,0,1,2,5} , *ip = arr+4; printf("%d\n",ip[1]); ip is an integer pointer that is currently holding the address where 5 is stored.(i.e. a[4]) ip[1] = *(ip+1) = value present at the next address i.e. 6. so it will print 6. Satbir answered Feb 12, 2019 Satbir comment Share Follow See all 0 reply Please log in or register to add a comment.
5 votes 5 votes arr+0 points to the 1st element of the array(index 0) which is 1. Hence arr+4 will point to the 5th element of the array(index 4) which is 5. As per assignment $*ip=arr+4$ , $ip[0]=5$ Hence $ip[1]=6$ Sayan Bose answered Feb 7, 2019 Sayan Bose comment Share Follow See all 0 reply Please log in or register to add a comment.