Question: In C++ please Two doubles are read from input as variables time1 and time2. Declare a vector of doubles named swimmingTime and initialize the elements

In C++ please

Two doubles are read from input as variables time1 and time2. Declare a vector of doubles named swimmingTime and initialize the elements at the odd indices with the value 0 and the even indices with the variables time1 and time2 in the order the input doubles are read.

Ex: If the input is 5.34 22.05, then the output is: 5.34 0 22.05 0

Note: Index 0 is considered an even index.

Given Code:

#include #include using namespace std;

int main() { double time1; double time2; unsigned int i;

cin >> time1; cin >> time2; //your code goes here for (i = 0; i < swimmingTime.size(); ++i) { cout << swimmingTime.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!