block.cpp 763 B

123456789101112131415161718192021222324
  1. // block.cpp -- use a block statement
  2. #include <iostream>
  3. int main()
  4. {
  5. using namespace std;
  6. cout << "The Amazing Accounto will sum and average ";
  7. cout << "five numbers for you.\n";
  8. cout << "Please enter five values:\n";
  9. double number;
  10. double sum = 0.0;
  11. for (int i = 1; i <= 5; i++)
  12. { // block starts here
  13. cout << "Value " << i << ": ";
  14. cin >> number;
  15. sum += number;
  16. } // block ends here
  17. cout << "Five exquisite choices indeed! ";
  18. cout << "They sum to " << sum << endl;
  19. cout << "and average to " << sum / 5 << ".\n";
  20. cout << "The Amazing Accounto bids you adieu!\n";
  21. // cin.get();
  22. // cin.get();
  23. return 0;
  24. }