Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int num1, num2, subtotal, average, total;
- cout << "Enter integers for start and finish in pairs until start > finish";
- cout << ", which terminates the program or when EOF or an invalid input";
- cout << "has been made." << endl << endl;
- cout << "Enter start and finish integers -> ";
- cin >> num1 >> num2;
- total = 0;
- if(cin.eof()) cout << "EOF..." << endl;
- if(cin.fail()) cout << "FAIL..." << endl;
- while (num1 <= num2)
- {
- subtotal = (num1 * num1);
- total = subtotal + total;
- num1++;
- cout << "SUBTOTAL = " << subtotal << endl; // TESTING PURPOSES
- cout << "TOTAL = " << total << endl; // TESTING PURPOSES
- }
- if (num1 > num2)
- {
- average = (total / 2);
- cout << "TOTAL = " << total << endl;
- cout << "AVERAGE = " << average << endl;
- }
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment