pastebin

Paste Search Dynamic
Recent pastes
calcAverage
  1. #include <stdio.h>
  2.  
  3. typedef struct{
  4.         int mth;
  5.         int eng;
  6.         int phy;
  7.         int avg;
  8. } Score;
  9.  
  10. void calcAverage(Score s[], int n);
  11.  
  12. int main(void) {
  13.         Score s[] = {{65,80,95,80},
  14.         {70,68,75,71},{60,100,83,81},{100,55,74,76},{90,85,100,91}
  15.  
  16.                
  17.  
  18.         };
  19.         int i, n=5;
  20.  
  21.         calcAverage(s, n);
  22.  
  23.         for(i=0; i<n; i++ )
  24.                 printf( "[%d] %4d %4d %4d %4dn", i, s[i].mth, s[i].eng, s[i].phy, s[i].avg );
  25.  
  26.         return 0;
  27. }
  28.  
  29. void calcAverage(Score s[], int n){
  30. int i;
  31. for(i=0;i<n;i++){
  32.         s[i].avg=(s[i].mth+s[i].eng+s[i].phy/3.0);
  33. }
  34.  
  35.  
  36. }
  37.  
Parsed in 0.009 seconds