132k views
1 vote
1. Assume that the vector monthSales of integers has already been declared and that its elements contain sales data for the 12 months of the year in order (i.e., January, February, etc.).Write a statement that writes to standard output the element corresponding to October.2.Assume that the vector arr has been declared. In addition, assume that VECTOR_SIZE has been defined to be an integer that equals the number of elements in arr .Write a statement that assigns the next to last element of the vector to the variable x ( x has already been declared).3. Given an vector a , declared to contain 34 elements, write an expression that refers to the last element of the vector. Please do not use member function to solve this problem

User Alfakini
by
6.1k points

1 Answer

4 votes

Answer:

1. cout << monthSales[9];

2. arr[VECTOR_SIZE - 2] = x;

3. cout << a[33];

Step-by-step explanation:

In the given question the programming language is not mentioned to write the statements, so the statements are written in C++ programming language.

1.

Although months are between 1-12. Therefore, in January we can mark as element 0, February as element 1, and so on. So October, which was initially 10, was numbered 9.

2.

The second to last dimension is the next to the last element. The final element is smaller than the actual vector scale. The next place to the last element would, therefore, be two less than the vector size.

3.

The last element of the vector array is one less than the total vector number since vectors start at 0.

User Stacked
by
6.1k points