Question: How do I create a flowchart for this? (pdf or word document would be helpful so I could zoom in) #include #include int main(int argc,
How do I create a flowchart for this? (pdf or word document would be helpful so I could zoom in)
#include #include
int main(int argc, char** argv) {
// Declaring Variables int gameScores[100][2]; int size=0; char userInput; while(1) { printf ("*********************************************** "); printf ("** MAIN MENU ** "); printf ("*********************************************** "); printf ("A) Enter game results "); printf ("B) Current Record (# of wins and # of losses and # of ties) "); printf ("C) Display ALL results from all games WON "); printf ("D) Display ALL results ordered by opponent score from low to high "); printf ("E) Quit "); printf ("Enter an option from the main menu "); scanf (" %c", &userInput); if(userInput == 'E') { break; } else if (userInput == 'A') { scanf("%d %d", &gameScores[size][0], &gameScores[size][1]); size += 1; printf(" "); } else if (userInput == 'B') { // Count number of wins, ties, losses int wins = 0, losses = 0, ties =0; for(int i = 0; i if(gameScores[i][0] > gameScores[i][1]) { wins++; } else if (gameScores[i][0] < gameScores[i][1]) { losses++; } else { ties++; } } printf("Current Record of Wins : %d, Losses : %d, Ties : %d ", wins, losses, ties); } else if (userInput == 'C'){ //print results from all games won by the user printf ("Results from all games WON : "); for(int i = 0; i if(gameScores[i][0] > gameScores[i][1]) { printf("Score of Your Team : %d, Score of Other Team : %d ", gameScores[i][0], gameScores[i][1]); } } printf (" "); } else if (userInput == 'D') { //Using selection sort algorithm int i, j, minIndex, temp; for(int i = 0; i minIndex = i; for (j=i+1; j if(gameScores[j][1] < gameScores[minIndex][1]){ minIndex = j; } } // Swap the values temp = gameScores[minIndex][1]; gameScores[minIndex][1] = gameScores[i][1]; gameScores[i][1] = temp; // Arrange the user scores as well temp = gameScores[minIndex][0]; gameScores[minIndex][0] = gameScores[i][0]; gameScores[i][0] = temp; } printf ("Results ordered by oppoenent score : " ); for(int i = 0; i printf("Score of Your Team : %d, Score of Other Team : %d ", gameScores[i][0], gameScores[i][1]); } printf (" "); } } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
