Question: Complete or if needed modify this C++ code following the instructions. #include //Define function prototype float computeAvg (int arr[ ], int len); int main() {
Complete or if needed modify this C++ code following the instructions.

#include
//Define function prototype float computeAvg (int arr[ ], int len);
int main() {
/* Declare variables */ char firstName [3][30]; char lastName [3][30]; int scores [3][6]; int sum[3]; double avg[3]; int i,j,k; int num,sumatory; int winner;
FILE *fp; // define pointer variable of type FILE
/* Open data file associated with fp in read mode */ fp = fopen("data.txt", "r");
/* Check if open was successful */ if (fp == NULL) // Not successful { printf("Program cannot open the file "); return -1; // indicates a problem; if you have this, // no need for else below }
else // strictly speaking not required, but helps mark place {
/* Prompt and read in values */
//for(k=0;k
{ //for(k=0;k scores[k][j + 1]) { num = scores[k][j]; scores[k][j] = scores[k][j+1]; scores[k][j+1] = num; } } } /* Sort Array*/
/*Determine minimum score */
//for(k=0;k
/* Determine maximum score */
//for(k=0;k
/* Sum up all six scores in array and store in sum array */
//for(k=0;k
/* Subtract min and max from sum */
//for(k=0;k
/*Compute adjusted average of remaining four score sum */ for(k=0;k
} winner = 0; if(avg[0] > avg[1] && avg[0] > avg[2]) winner = 0; else if (avg[1] > avg[0] && avg[1] > avg[2]) winner = 1; else winner = 2; printf("The gold-medal winner is %s %s with an average score of %lf ",firstName[winner],lastName[winner],avg[winner]); } fclose(fp);
return(0); } } //Function float computeAvg (int arr[ ], int len) { int i; int sumatory = 0; double average; for (i=0; i

Description:
The topic of this programming assignment is the same as Lab #2 and Lab #3: determining the gold-medal winner of a halfpipe snowboarding competition, based on scores that are examples of actual data compiled and analyzed during the recent winter Olympic Games in South Korea. In this lab, you will be modifying your code from Lab #3.
New requirement for this lab: Instead of having all statements inside of the main function, in this lab you will define two additional functions that will be called from main. One new function will simply display a message or instructions (your choice of content) when called from main. For the second new function, you will identify a task that could be removed from main and placed in a separate function, define the function that handles that task, and call that function from main.
Instructions:
First, add a function named printMsg that displays a message, a greeting, or an introduction to the program for the user. Add a statement that calls that function from the main function when your program starts. This function does not return anything, and you may define your own message. Define this function below main, and add a function prototype statement at top of your program to avoid creating an error flagged by the compiler.
Next, examine your Lab 3 code to identify a computational task that could be successfully removed from main and placed in a separate function instead. Examples of discrete tasks might include:
Identifying the minimum value in an array
Identifying the maximum value in an array
Computing the sum and/or average of values in an array
Define the function to complete the task, placing it below main. You will need to provide a name for this function that matches the task that it performs. Add a function prototype statement for this function at the top of your program. Add the statement to main that will call this function and handle what is returned. Comment out the lines no longer needed in main.
Test your program using the same data file as used for Lab 3. Your program should produce the identical results as obtained with your program from Lab 3 (with the addition of the greeting/introduction).

Sean White 96 98 88 99 98 100 Chloe Kim 92 99 100 98 99 97 Ben Ferguson 90 95 91 85 94 88 St. Bernard 99 97 100 98 99 100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
