Advertisement
Aminpro

[ECP 1016]Tutorial 6 & 7 Question 4

Aug 2nd, 2012
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1. //https://www.facebook.com/AminproPastebin
  2.  
  3. #include <stdio.h>
  4.  
  5. void mean (float mun[], int size);
  6.  
  7. int main(){
  8.    
  9.     int size=0;
  10.     float insert=0;
  11.     int i;
  12.    
  13.     printf("Please enter the size of array:");
  14.     scanf("%d", &size);
  15.     float mun[size];
  16.                 for(i=0; i<=size - 1; i++){
  17.    
  18.                          printf("Please enter numbers to be inserted into array:");
  19.                          scanf("%f", &insert);
  20.                          mun[i] = insert;
  21.                              }
  22.    
  23.     mean (mun, size);
  24.    
  25.    
  26.     getchar();
  27.     getchar();
  28.     getchar();
  29.     getchar();
  30.     getchar();
  31.    
  32.     }
  33.  
  34.  
  35. void mean (float mun[], int size){
  36.      float total=0;
  37.      int i;
  38.      float sum=0;
  39.      for(i=0; i<=size-1; i++){
  40.               total = mun[i] + total;
  41.               }
  42.      sum = total/size;
  43.      printf("The average is %f", sum);
  44.      
  45.      
  46.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement