Advertisement
rafikamal

Average of the numbers

Jan 11th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.23 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int sum = 0;
  6.     int n;
  7.     int i = 0;
  8.  
  9.     while(scanf("%d", &n) != EOF)
  10.     {
  11.         sum += n;
  12.         i++;
  13.     }
  14.  
  15.     printf("Average is: %lf\n", sum*1.0 / i);
  16.  
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement