Advertisement
thenewboston

C Programming Tutorial - 40 - Why I am Banned from Fantasy H

Aug 22nd, 2014
539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <math.h>
  6.  
  7. int main()
  8. {
  9.     int i;
  10.     int player[5] = {58, 66, 68, 71, 87};
  11.     int goals[5] = {26, 39, 25, 29, 31};
  12.     int gamesPlayed[5] = {30, 30, 28, 30, 26};
  13.     float ppg[5];
  14.     float bestPPG = 0.0; //best players PPG
  15.     int bestPlayer;
  16.  
  17.     printf("Player \t Goals \t GP \t PPG \n");
  18.  
  19.     for(i=0; i<5; i++){
  20.         //player, goals, gamesPlayed, ppg
  21.         ppg[i] = (float)goals[i] / (float)gamesPlayed[i];
  22.         printf("%d \t %d \t %d \t %.2f \n", player[i], goals[i], gamesPlayed[i], ppg[i]);
  23.  
  24.         if(ppg[i] > bestPPG){
  25.             bestPPG = ppg[i];
  26.             bestPlayer = player[i];
  27.         }
  28.  
  29.     }
  30.  
  31.     printf("\nThe best player is %d \n", bestPlayer);
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement