Question: Given the double vector myValues with one element, the input integer newSize, and the input double startNum, resize myValues to newSize. Then, assign the new

Given the double vector myValues with one element, the input integer newSize, and the input double startNum, resize myValues to newSize. Then, assign the new elements of myValues with startNum -0.5* i, where i is the index of each element in the vector.
Ex: If the input is 313.5, then the output is:
39.513.012.5 #include
#include
#include
using namespace std;
int main(){
unsigned int i;
int initSize =1;
vector myValues(initSize);
int newSize;
double startNum;
myValues.at(0)=39.5;
cin >> newSize;
cin >> startNum;
for (int i =0; i < startNum.at(i); ++i){
startNum.at(i)= startNum.at(i)*-0.5;
}
for (i =0; i < myValues.size(); ++i){
cout << fixed << setprecision(1)<< myValues.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 Databases Questions!