Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to create a flow chart for this code? #include #include int main(int argc, char** argv) { int gameScores[100][2]; int size = 0; char userInput;

How to create a flow chart for this code?

#include #include int main(int argc, char** argv) {

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_s(" %c", &userInput);

if (userInput == 'E') { break; } else if (userInput == 'A') { scanf_s("%d %d", &gameScores[size][0], &gameScores[size][1]); size += 1; printf(" "); } else if (userInput == 'B') { int wins = 0, losses = 0, ties = 0; for (int i = 0; i < size; 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') { printf("Results from all games WON : "); for (int i = 0; i < size; 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') { int i, j, minIndex, temp; for (int i = 0; i < size; i++) { minIndex = i; for (j = i + 1; j < size; j++) { if (gameScores[j][1] < gameScores[minIndex][1]) { minIndex = j; } } temp = gameScores[minIndex][1]; gameScores[minIndex][1] = gameScores[i][1]; gameScores[i][1] = temp;

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 < size; 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions