Guest User

AVG-CALC

a guest
Oct 4th, 2011
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. main(){
  4.  int nums, totaln, totalo=0, add;
  5.  float avg;
  6.  printf("How many numbers do you want to average?");
  7.  scanf("%d", &nums);
  8.  for (int i=0; i<nums; i++){
  9.   scanf("%i", &add);
  10.   totaln=totalo+add;
  11.   printf("%i", totaln);
  12.   totalo=totaln
  13.  }
  14.  avg=totaln/nums
  15.  printf("The average of your numbers is %.3f.", avg);
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment