Complete the following vectors utilizing the C++ : 1. Assume that an vector of i
ID: 3626380 • Letter: C
Question
Complete the following vectors utilizing the C++ :
1. Assume that an vector of integers named salarySteps that contains exactly five elements has been declared.
Write a statement that assigns the value 160000 to the last element of the vector salarySteps
2.
Assume that an vector of int variables named salarySteps that contains exactly five elements has been declared.
Write a single statement to assign the value 30000 to the first element of this vector.
3. Given that an vector of int named a has been declared, assign 3 to its first element.
Explanation / Answer
1. salarySteps[4] = 160000; the last element is one less than the number of elements. 2. salarySteps[0] = 30000; the first element always starts at 0. 3. a[0] = 3; considering that the first element exists, this would work. if the vector does not contain the first element, you would need to use the member function push_back like so: a.push_back(3);