Assume that a program creates and initializes a Short Integer variable named age and a pointer named agePtr, to which it assigns the address of the age variable. Which of the following statements will assign the number 21 to the age variable?

age = 21;
*age = 21;
agePtr = 21;
*agePtr = 21; E. both (a) and (d)

The correct answer is: A. age = 21;

Option A assigns the number 21 to the age variable.

Option B assigns the number 21 to the memory location pointed to by the age variable. This will not change the value of the age variable itself.

Option C assigns the address of the age variable to the agePtr pointer. This will not change the value of the age variable itself.

Option D assigns the number 21 to the memory location pointed to by the agePtr pointer. This will not change the value of the age variable itself.

Option E is incorrect because it includes both Option A and Option D. Option A is the only option that will assign the number 21 to the age variable.

Exit mobile version