146k views
3 votes
Consider int ia[2], *ip; ip = &ia; ia[0] = 1; ia[1]=2; *ip = *ip-1; What is the value of ia[0]?

User Bomi
by
7.8k points

1 Answer

5 votes

Final answer:

The value of ia[0] is 0.

Step-by-step explanation:

The value of ia[0] can be determined by following the given code. In the code snippet, we have an integer array ia[2] and a pointer *ip. The pointer ip is assigned the address of the first element of the array ia. Therefore, *ip refers to the value stored in the first element of the array.

Next, the first element of the array is assigned the value of *ip minus 1. Since the initial value of *ip was 1, subtracting 1 gives us 0. Therefore, ia[0] will have the value of 0.

User Dodomorandi
by
9.0k points