Answer :
Final answer:
The correct way to assign the last element of a 16-element vector with the value 99 is option (c) (15) = 99, since array indexing typically starts at 0, making 15 the index of the last element.
Explanation:
To determine which option correctly assigns the vector's last element with 99, it's essential to understand that in most programming languages, array indexing starts at 0. Therefore, if a vector has 16 elements, they are indexed from 0 to 15. To assign a value to the last element of this vector, you'd use the index 15.
Based on this information, the answer is:
- (a) (0) = 99; Incorrect - This would change the first element to 99, not the last.
- (b) (14) = 99; Incorrect - This would change the second to last element to 99.
- (c) (15) = 99; Correct - This will assign the last element of a 16-element vector with the value 99.
- (d) (16) = 99; Incorrect - This would result in an 'Index Out of Bounds' error, as there is no 17th element in a 16-element vector.