Question
Question: I need a step by step walkthrough of the code if possible(basically comments) #define _CRT_SECURE_NO_WARNINGS #include #define MAX_JUDGES 3 #define MAX_STRING 25 #define MAX_CONTESTANTS
Question:
I need a step by step walkthrough of the code if possible(basically comments)
#define _CRT_SECURE_NO_WARNINGS
#include
#define MAX_JUDGES 3
#define MAX_STRING 25
#define MAX_CONTESTANTS 10
#define WINNER_CUTOFF 6.5
struct Score { double judgeScore[MAX_JUDGES]; };
struct Contestant { char name[MAX_STRING]; struct Score score; double average; };
struct Competition { char compName[MAX_STRING]; struct Contestant contestants[MAX_CONTESTANTS];
int numContestants; };
double avg(const struct Contestant* c) { return (c->score.judgeScore[0] + c->score.judgeScore[1] + c->score.judgeScore[2]) / 3.0; }
int main(void) {
struct Contestant winners[MAX_CONTESTANTS] = { { 0 } };
struct Competition national = { "National", { { "Jill Smith", { { 4.4 , 8 , 7 } }}, { "Ellen Jones", { { 7.5 , 5.5 , 8 } }}, { "Joan Bell", { { 6.5 , 5.5 , 7 } }}, }, 3 };
int i, j, k, numWinners = 0;
for (i = 0; i
if (national.contestants[i].average >= WINNER_CUTOFF) {
for (j = 0; j
// no code to see here }
for (k = numWinners; k > j; k--) {
winners[k] = winners[k - 1]; } winners[j] = national.contestants[i]; numWinners++; } }
printf("Winners of the %s competition ", national.compName);
for (i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started