88.2k views
0 votes
Consider int ia[2], *ip; ip = &ia; ia[0] = 1; ia[1]=2; *(ip + 1) = *ip+1; What is the value of ia[1]?

User Aarti Oza
by
8.1k points

1 Answer

4 votes

Final answer:

The value of ia[1] is 2.

Step-by-step explanation:

The given code initializes an integer array ia of size 2, and a pointer variable ip. The pointer ip is then assigned the address of the array ia. The elements of the array ia are then assigned values 1 and 2.

The expression *(ip + 1) = *ip + 1 means that the value at the address (ip + 1) is updated with the value at the address ip plus 1. In this case, the value at the address ip is 1, so the value at the address (ip + 1) becomes 1 + 1 = 2.

Therefore, the value of ia[1] is 2.

User Ederollora
by
7.7k points