Guest User

Untitled

a guest
Jan 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7. int userNumber = 0;
  8.  
  9. int count = 0;
  10.  
  11. int sum = 0;
  12.  
  13. float average;
  14.  
  15. int max;
  16.  
  17. int min;
  18.  
  19. while(1) {
  20.  
  21. cout << "Enter a number, -1 to exit" << endl;
  22.  
  23. cin >> userNumber;
  24.  
  25. if(userNumber == -1)
  26.  
  27. break;
  28.  
  29. else {
  30.  
  31. if(count == 0) {
  32.  
  33. min = userNumber;
  34.  
  35. }
  36.  
  37. if(count == 0) {
  38.  
  39. max = userNumber;
  40.  
  41. }
  42.  
  43. count++;
  44.  
  45. sum = sum + userNumber;
  46.  
  47. if (min > userNumber) {
  48.  
  49. min = userNumber;
  50.  
  51. }
  52.  
  53. if (max < userNumber) {
  54.  
  55. max = userNumber;
  56.  
  57. }
  58.  
  59. }
  60.  
  61. }
  62.  
  63. average = (float) sum/count ;
  64.  
  65. cout << "According to my calculations . . . " << endl;
  66.  
  67. cout << "The amount of numbers is: " << count << endl;
  68.  
  69. cout << "Total sum of these names: " << sum << endl;
  70.  
  71. cout << "The average is: " << average << endl;
  72.  
  73. cout << "The maximum is: " << max << endl;
  74.  
  75. cout << "The minimum is: " << min << endl;
  76.  
  77. cin.get();
  78.  
  79. cin.get();
  80.  
  81. cin.get();
  82.  
  83. cin.get();
  84.  
  85. return 1;
  86.  
  87. }
Add Comment
Please, Sign In to add comment