Answer:
In C++:
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int main(){
vector<double> myvector;
double userinput;
cout<<"Enter 5 numbers: ";
for (int i = 1; i <= 5; i++){
cin>>userinput;
myvector.push_back(userinput);
}
for (int i = 0; i < 5; i++){
cout << fixed << setprecision(2)<< myvector.at(i) <<' ';
}
return 0;
}
Explanation:
This declares the vector as double
vector<double> myvector;
This declares a variable for input as double
double userinput;
This prompts the user for input of 5 numbers
cout<<"Enter 5 numbers: ";
This iterates from 1 to 5
for (int i = 1; i <= 5; i++){
This gets each integer input
cin>>userinput;
This pushes each input into the vector
myvector.push_back(userinput); }
This iterates through the vector
for (int i = 0; i < 5; i++){
This prints each vector element separated by space using fixed setprecision
cout << fixed << setprecision(2)<< myvector.at(i) <<' ';
}