Advertisement
Mary_99

ex.2.6

Nov 27th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7.     float a;
  8.     float b = 0;
  9.     float avr =1;
  10.     float amount = 0;
  11.  
  12.  
  13.     printf("enter the number:  ");
  14.     scanf ("%f", &a);
  15.  
  16.     while(a != 0 )
  17.     {
  18.         if( fabs(a)<100)
  19.             amount++;
  20.  
  21.         if (a > 0)
  22.         {
  23.             avr = ((avr * b )+ a)/(b+1);
  24.             b++;
  25.         }
  26.         printf("enter the number:  ");
  27.         scanf ("%f", &a);
  28.     }
  29. printf( "Average is equal = %f and the number of numbers les than 100 =  %f", avr,amount);
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement