Which of the following statements outputs the value of the gpa member of element 1 of the student array?

A.
cout << student1.gpa;

B.
cout << firstStudent.gpa;

C.
cout << student[1].gpa;

D.
cout << student1->gpa;

Respuesta :

Answer:

The correct answer for the given question is option(c) i.e

cout << student[1].gpa;

Explanation:

In the given question gpa is the member of array student which index or element value is 1.

To access that member of array student we using the following syntax i.e

arrayname[index no or element no].variable name

In the option(A) the square bracket is not mention that's why it is incorrect option.

In the option(B) the array name is wrong i.e  firstStudent  that's why it is incorrect option.

In the option(D) the square bracket is not mention as well as -> operator is used to access member of array that's why it is incorrect option.

So student[1].gpa; is the correct statement which option is A cout << student1.gpa;.