Skip to main content
edited body
Source Link
200_success
  • 145.6k
  • 22
  • 191
  • 481

You can simplify your code greatly, amdand make it more general-purpose, by using an array for the scores, rather than individual variables. So change e.g.

double scores, avgValue, judge1, judge2, judge3, judge4, judge5;

to

double scores[5], avgValue;

and use a loop to read in the five scores.

You'll also want to change functions such as calcScore so that they take an array rather than separate scores, e.g.

double calcScore(double scores[], int num_scores)
{
    // ...
}

You can simplify your code greatly, amd make it more general-purpose, by using an array for the scores, rather than individual variables. So change e.g.

double scores, avgValue, judge1, judge2, judge3, judge4, judge5;

to

double scores[5], avgValue;

and use a loop to read in the five scores.

You'll also want to change functions such as calcScore so that they take an array rather than separate scores, e.g.

double calcScore(double scores[], int num_scores)
{
    // ...
}

You can simplify your code greatly, and make it more general-purpose, by using an array for the scores, rather than individual variables. So change e.g.

double scores, avgValue, judge1, judge2, judge3, judge4, judge5;

to

double scores[5], avgValue;

and use a loop to read in the five scores.

You'll also want to change functions such as calcScore so that they take an array rather than separate scores, e.g.

double calcScore(double scores[], int num_scores)
{
    // ...
}
Source Link
Paul R
  • 425
  • 2
  • 14

You can simplify your code greatly, amd make it more general-purpose, by using an array for the scores, rather than individual variables. So change e.g.

double scores, avgValue, judge1, judge2, judge3, judge4, judge5;

to

double scores[5], avgValue;

and use a loop to read in the five scores.

You'll also want to change functions such as calcScore so that they take an array rather than separate scores, e.g.

double calcScore(double scores[], int num_scores)
{
    // ...
}