fork download
  1. // This program averages 3 test scores. It repeats as
  2. // many times as the user wishes.
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int score1, score2, score3; // Three scores
  9. double average; // Average score
  10. char again; // To hold Y or N input
  11.  
  12. do
  13. {
  14. // Get three scores.
  15. cout << "Enter 3 scores and I will average them: ";
  16. cin >> score1 >> score2 >> score3;
  17.  
  18. // Calculate and display the average.
  19. average = (score1 + score2 + score3) / 3.0;
  20. cout << "The average is " << average << ".\n";
  21.  
  22. // Does the user want to average another set?
  23. cout << "Do you want to average another set? (Y/N) ";
  24. cin >> again;
  25. } while (again == 'Y' || again == 'y');
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Enter 3 scores and I will average them: The average is -4.58071e+08.
Do you want to average another set? (Y/N)