Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- #include <math.h>
- int main()
- {
- int i;
- int player[5] = {58, 66, 68, 71, 87};
- int goals[5] = {26, 39, 25, 29, 31};
- int gamesPlayed[5] = {30, 30, 28, 30, 26};
- float ppg[5];
- float bestPPG = 0.0; //best players PPG
- int bestPlayer;
- printf("Player \t Goals \t GP \t PPG \n");
- for(i=0; i<5; i++){
- //player, goals, gamesPlayed, ppg
- ppg[i] = (float)goals[i] / (float)gamesPlayed[i];
- printf("%d \t %d \t %d \t %.2f \n", player[i], goals[i], gamesPlayed[i], ppg[i]);
- if(ppg[i] > bestPPG){
- bestPPG = ppg[i];
- bestPlayer = player[i];
- }
- }
- printf("\nThe best player is %d \n", bestPlayer);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement