Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int userNumber = 0;
- int count = 0;
- int sum = 0;
- float average;
- int max;
- int min;
- while(1) {
- cout << "Enter a number, -1 to exit" << endl;
- cin >> userNumber;
- if(userNumber == -1)
- break;
- else {
- if(count == 0) {
- min = userNumber;
- }
- if(count == 0) {
- max = userNumber;
- }
- count++;
- sum = sum + userNumber;
- if (min > userNumber) {
- min = userNumber;
- }
- if (max < userNumber) {
- max = userNumber;
- }
- }
- }
- average = (float) sum/count ;
- cout << "According to my calculations . . . " << endl;
- cout << "The amount of numbers is: " << count << endl;
- cout << "Total sum of these names: " << sum << endl;
- cout << "The average is: " << average << endl;
- cout << "The maximum is: " << max << endl;
- cout << "The minimum is: " << min << endl;
- cin.get();
- cin.get();
- cin.get();
- cin.get();
- return 1;
- }
Add Comment
Please, Sign In to add comment