Question: Given the double vector valElements with two elements, the input integer listSize, and the input double begNum, resize valElements to listSize. Then, assign the new

Given the double vector valElements with two elements, the input integer listSize, and the input double begNum, resize valElements to listSize. Then, assign the new elements of valElements with begNum *(i /2+1), where i is the index of each new element in the vector.
Ex: If the input is 60.5, then the output is:
24.528.51.01.01.51.5
#include
#include
#include
using namespace std;
int main(){
unsigned int i;
int initSize =2;
vector valElements(initSize);
int listSize;
double begNum;
valElements.at(0)=24.5;
valElements.at(1)=28.5;
cin >> listSize;
cin >> begNum;
/* Your code goes here */
for (i =0; i < valElements.size(); ++i){
cout << fixed << setprecision(1)<< valElements.at(i)<<"";
}
cout << endl;
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!