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
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
Get step-by-step solutions from verified subject matter experts
