An array containing 10 predefined double values are already provided for you in the code editor. Print each of the element out in separate lines, starting from the last array element down to the first.
Each outputted value must also only show up to two decimal places.
Output
Multiple lines containing a float number.
5.10
5.50
4.00
4.02
3.00
3.66
2.50
2.20
1.21
1.40
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
double arr[10] ={2.4, 4.123, 5.9, 1.23, 5, 1, 45.567, 23, 8.974, 10.3};
for(int i = 9; i >=0; --i) {
cout<<setw(6) <<fixed <<setprecision(2)<< arr[i] << endl;
}
return 0;
}
Comments
Leave a comment