Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello. Please help me do this C program. Make sure that the code has functions.

ID: 3889918 • Letter: H

Question

 Hello. Please help me do this C program. Make sure that the code has functions. Writing comments and clear codes will be appreciated. Thank you!  ARRAY PROGRAM  You are to write a C program that keeps track of a season of games for your  favorite sports team. The program will store the results for between 0  and 1000 game results.  The program will have a menu that MAY look like the  following:  *********************************************** **                  MAIN   MENU              ** *********************************************** A) Enter game results B) Current Record (# of wins and # of losses) C) Display ALL results from all games WON D) Display ALL results E) Quit   The game results will simply be the score by your team and the score by your opponent. You will not need the date of the game. 

Explanation / Answer

C CODE:

#include <stdio.h>


int main()
{
int wins = 0;
int losses = 0;
int myteam_scores[1000]; int opponent_scores[1000];
int matches = 0;

while(1)
{
    printf("%s ", " Select A To Enter Game Results Select B To Current Record (# of wins and # of losses) Select C To Display ALL results from all games WON Select D To Display ALL results Select E To Quit ");
    char choice;
    scanf("%s",&choice);
    if(choice == 'A')
    {
      printf("%s ", "Enter 1 if your team won, else enter 0!");
      int tmp;
      scanf("%d",&tmp);
      if(tmp == 1)
      {
       wins = wins + 1;
      }
      else
      {
       losses = losses + 1;
      }
      printf("%s ", "Enter score of your team!");
      scanf("%d",&myteam_scores[matches]);
      printf("%s ", "Enter score of opponent team!");
      scanf("%d",&opponent_scores[matches]);            
      matches = matches + 1;
    }
    else if(choice == 'B')
    {
      printf("%s %d ", "Number of wins = ",wins );
      printf("%s %d ", "Number of losses = ",losses );
    }
    else if(choice == 'C')
    {
      for (int i = 0; i < matches; ++i)
      {
       if(myteam_scores[i] >= opponent_scores[i])
       {
        printf("%s %d %s ","Game number ", i+1, " : My team won!" );
        printf("%s %d %s %d ","My team's score: ", myteam_scores[i],"opponent's score: ", opponent_scores[i]);
       }
      }       
    }
    else if(choice == 'D')
    {
      for (int i = 0; i < matches; ++i)
      {
       if(myteam_scores[i] >= opponent_scores[i])
       {
        printf("%s %d %s ","Game number ", i+1, " : My team won!" );
        printf("%s %d %s %d ","My team's score: ", myteam_scores[i],"opponent's score: ", opponent_scores[i]);
       }
       else
       {
        printf("%s %d %s ","Game number ", i+1, " : My team lost!" );
        printf("%s %d %s %d ","My team's score: ", myteam_scores[i],"opponent's score: ", opponent_scores[i]);
       }
      }
    }
    else if(choice == 'E')
    {
      printf("%s ", "Thank you!");
      break;
    }
    else
    {
      printf("%s ", "Invalid input!");
      break;
    }   
    }
    return 0;
}

SAMPLE OUTPUT:

Select A To Enter Game Results
Select B To Current Record (# of wins and # of losses)
Select C To Display ALL results from all games WON
Select D To Display ALL results
Select E To Quit
A
Enter 1 if your team won, else enter 0!
1
Enter score of your team!
100
Enter score of opponent team!
0


Select A To Enter Game Results
Select B To Current Record (# of wins and # of losses)
Select C To Display ALL results from all games WON
Select D To Display ALL results
Select E To Quit
A
Enter 1 if your team won, else enter 0!
1
Enter score of your team!
100
Enter score of opponent team!
50


Select A To Enter Game Results
Select B To Current Record (# of wins and # of losses)
Select C To Display ALL results from all games WON
Select D To Display ALL results
Select E To Quit
A
Enter 1 if your team won, else enter 0!
0
Enter score of your team!
50
Enter score of opponent team!
100


Select A To Enter Game Results
Select B To Current Record (# of wins and # of losses)
Select C To Display ALL results from all games WON
Select D To Display ALL results
Select E To Quit
B
Number of wins = 2
Number of losses = 1


Select A To Enter Game Results
Select B To Current Record (# of wins and # of losses)
Select C To Display ALL results from all games WON
Select D To Display ALL results
Select E To Quit
C
Game number 1 : My team won!
My team's score: 100 opponent's score: 0
Game number 2 : My team won!
My team's score: 100 opponent's score: 50


Select A To Enter Game Results
Select B To Current Record (# of wins and # of losses)
Select C To Display ALL results from all games WON
Select D To Display ALL results
Select E To Quit
D
Game number 1 : My team won!
My team's score: 100 opponent's score: 0
Game number 2 : My team won!
My team's score: 100 opponent's score: 50
Game number 3 : My team lost!
My team's score: 50 opponent's score: 100


Select A To Enter Game Results
Select B To Current Record (# of wins and # of losses)
Select C To Display ALL results from all games WON
Select D To Display ALL results
Select E To Quit
E
Thank you!