volkovich_maksim

avg_overflow

Sep 14th, 2016
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void){
  4.     int qualifier, count=0;
  5.     long int inp_number, min, max;
  6.     float sum = 0;
  7.     float average;
  8.     qualifier = scanf("%ld", &inp_number);
  9.     if (qualifier  == 1){
  10.         for (min = max = inp_number; qualifier == 1; count ++){
  11.             if (inp_number > max){
  12.                 max = inp_number;
  13.             }
  14.             else if (inp_number < min){
  15.                 min = inp_number;
  16.             }
  17.             sum += inp_number;
  18.             qualifier = scanf("%ld", &inp_number);
  19.         }
  20.         average = sum / count;
  21.         printf("average is ");
  22.         printf("%f\n", average);
  23.         printf("max is ");
  24.         printf("%ld\n", max);
  25.         printf("min is ");
  26.         printf("%ld\n", min);
  27.     }
  28.     return 0;
  29. }
Add Comment
Please, Sign In to add comment