Getting a value between functions

Hi :)

I have a function that gets the lowest score out of a few integers.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//I'm not allowed to use arrays
 double findLowest(double score1, double score2,
	              double score3, double score4,
				  double score5,)
{
     double lowest = score1;

    if(lowest > score2)
    {
        lowest = score2;
    }

    if(lowest > score3)
    {
        lowest = score3;
    }

    if(lowest > score4)
    {
        lowest = score4;
    }

    if(lowest > score5)
    {
        lowest = score5;
    }

}


I also have another function that is supposed to calculate the scores.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void calcScore(double score1, double score2,
	           double score3, double score4,
			   double score5)
{
	// Get the lowest score.
    

	// Get the highest score.


	// Calculate the total of all five scores.


	// Drop the lowest and highest scores and calculate
	// the average of the three remaining scores.



	// Display the average score with the lowest
	// and highest score dropped.



}


My problem is that I don't know how to get the variable from the first function into another function. Any suggestions? Thank you!
closed account (E0p9LyTq)
Use your calcScore() function to call other functions, such as findLowest(). You already have the 5 scores in calcScore(), just pass those values to other functions.

By your comments in calcScore(), you could create 5 functions, one to perform the work outlined in each comment. The parameters of the first three functions could be all 5 scores, the parameters of the last two could be the 3 scores without the lowest and highest score.

Functions 4 and 5 could be combined into one function since displaying an average could be part of calculating the average of the 3 scores.

You could also drop function 3 and just do the summing of the 5 scores in your calcScore() function.
Last edited on
Topic archived. No new replies allowed.