Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5
https://code.sololearn.com/ctB4nrCajCd5 #include <iostream> using namespace std; int main(void) { int i; double sum, avg, min, max; double bankBalances[20] = {300.0, 500.0, 250.0, 600.0, 1000.0, 400.0, 800.0, 450.0, 600.0, 2200.0, 200.0, 900.0, 250.0, 650.0, 1200.0, 700.0, 500.0, 350.0, 700.0, 1600.0, }; /*for (i = 0; i < 20; i++) { cout << "Enter bank balance n°" << i << endl; cin >> bankBalances[i]; }*/ sum = 0; min = bankBalances[0]; max = bankBalances[0]; for (i = 0; i < 20; i++) { sum += bankBalances[i]; if (bankBalances[i] < min) { min = bankBalances[i]; } else if (bankBalances[i] > max) { max = bankBalances[i]; } } avg = sum / 20.0; cout << "Average: " << avg << endl; cout << "Minimum: " << min << endl; cout << "Maximum: " << max << endl; return 0; }
15th Oct 2016, 1:30 PM
Zen
Zen - avatar