Advertisement
volkovich_maksim

avg_nooverflow

Sep 14th, 2016
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 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 average;
  7.     qualifier = scanf("%ld", &inp_number);
  8.     if (qualifier  == 1){
  9.         average = inp_number;
  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.             average = (average/(count+1))*count + inp_number/(count+1);
  18.             qualifier = scanf("%ld", &inp_number);
  19.         }
  20.         printf("average is ");
  21.         printf("%f\n", average);
  22.         printf("max is ");
  23.         printf("%ld\n", max);
  24.         printf("min is ");
  25.         printf("%ld\n", min);
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement