asked 210k views
1 vote
PLEASE HELP

Four doubles are read from input as variables distance1 to distance4. Declare a vector of doubles named runningDistance and initialize the elements with the variables distance1 to distance4 in the order the input doubles are read.

Ex: If the input is 8.97 14.1 8.56 22.63, then the output is:

8.97 14.1 8.56 22.63
in c++

1 Answer

4 votes

Answer:

#include <iostream>

#include <vector>

int main() {

double distance1, distance2, distance3, distance4;

std::cin >> distance1 >> distance2 >> distance3 >> distance4;

std::vector<double> runningDistance = {distance1, distance2, distance3, distance4};

for (const auto &distance : runningDistance) {

std::cout << distance << " ";

}

std::cout << std::endl;

return 0;

}

Step-by-step explanation:

answered
User Hoffmania
by
7.7k points