fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. using namespace std;
  4.  
  5. int main(void)
  6. {
  7. int x,min,max,count=0,i,sum;
  8.  
  9. printf("Enter temperature data. To end sequence enter: -9999.\n\n");
  10. scanf("%i",&x);
  11. max = x;
  12. min = x;
  13. sum = x;
  14. while(count >= 0)
  15. {
  16. scanf("%i",&x);
  17.  
  18. if(x == -9999)
  19. break;
  20. else if(x < min)
  21. min = x;
  22. else if(x > max)
  23. x = max;
  24.  
  25. count++;
  26. sum = sum + x;
  27. }
  28. i = sum/count;
  29. printf("The Average of all entered values is: %+i.\n",sum);
  30. printf("The maximum value entered is: %+i\n",max);
  31. printf("The minimum value enterd is: %+i\n",min);
  32.  
  33.  
  34.  
  35.  
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 3300KB
stdin
10
20
30
40
-9999
stdout
Enter temperature data. To end sequence enter: -9999.

The Average of all entered values is: +40.
The maximum value entered is: +10
The minimum value enterd is: +10