fork(1) download
  1. //
  2. #include <iostream>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int main() {
  7. double score1, score2, score3, score4, score5;
  8. double average;
  9.  
  10. // Ask the user to enter five test scores
  11. cout << "Enter five test scores: 85, 92, 78, 88, 91\n";
  12. cin >> score1 >> score2 >> score3 >> score4 >> score5;
  13.  
  14. // Calculate the average
  15. average = (score1 + score2 + score3 + score4 + score5) / 5.0;
  16.  
  17. // Display the average in fixed-point notation with one decimal place
  18. cout << fixed << setprecision(1);
  19. cout << "The average test score is: 86.8" << average << endl;
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Enter five test scores: 85, 92, 78, 88, 91
The average test score is: 86.80.0