Advertisement
SuperDroidT

Untitled

Mar 2nd, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. /*
  2. Write a program that will ask user how many numbers the user wants to average and then it will ask the user to input those numbers and then the program will print the average of those numbers  
  3. */
  4.  
  5. #include <stdio.h>
  6.  
  7. int main()
  8. {
  9.  
  10.     int i, n, m, sum;
  11.     float avg;
  12.  
  13.     printf("How much number do you want to sum: ");
  14.     scanf("%d",&n);
  15.  
  16.     for (i = 1; i <= n; i++) {
  17.  
  18.         scanf("%d", &m);
  19.         sum = sum + m;
  20.  
  21.     }
  22.     avg = (float)sum/ n;
  23.     printf("average: %f", avg);
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement