Guest User

Untitled

a guest
Jul 17th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int num1, num2, subtotal, average, total;
  7.  
  8. cout << "Enter integers for start and finish in pairs until start > finish";
  9. cout << ", which terminates the program or when EOF or an invalid input";
  10. cout << "has been made." << endl << endl;
  11. cout << "Enter start and finish integers -> ";
  12. cin >> num1 >> num2;
  13. total = 0;
  14. if(cin.eof()) cout << "EOF..." << endl;
  15. if(cin.fail()) cout << "FAIL..." << endl;
  16. while (num1 <= num2)
  17. {
  18. subtotal = (num1 * num1);
  19. total = subtotal + total;
  20. num1++;
  21. cout << "SUBTOTAL = " << subtotal << endl; // TESTING PURPOSES
  22. cout << "TOTAL = " << total << endl; // TESTING PURPOSES
  23. }
  24. if (num1 > num2)
  25. {
  26. average = (total / 2);
  27. cout << "TOTAL = " << total << endl;
  28. cout << "AVERAGE = " << average << endl;
  29. }
  30. system("pause");
  31.  
  32. return 0;
  33. }
Add Comment
Please, Sign In to add comment