78.0k views
5 votes
Assume that ip has been declared to be a pointer to int and that enrollment has been declared to be an array of 20 elements . Assume also that section has been declared to be an int and has been initialized to some value between 5 and 10.Write a statement that makes ip point to the element in the array indexed by section

User AtineoSE
by
5.1k points

1 Answer

5 votes

Answer:

ip = enrollment + section;

Step-by-step explanation:

The variable ip has been declared to be a pointer to int.

int * ip;

The variable enrollment has been declared as an array of 20 elements .

int enrollment[20];

The variable section has been declared as an int.

int section;

In order to make ip point to the element in the array indexed by section, we can use the following statement :

ip = enrollment + section;

This will make ip point to enrollment[section].

User Juan Paredes
by
4.6k points