Answer to Question #337940 in C++ for Arraaaaayyyyyy 2.2

Question #337940

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

1
Expert's answer
2022-05-08T14:33:07-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS