Well, I revised my code, and this is what I came up with.
#include <iostream>
#include <conio>
using namespace std;
//Function prototype
void getscore(int&, int&, int&, int&, int&);
int findLowest (int, int, int, int, int);
void calcAverage (int, int, int, int, int, int, int);
int main()
{
int average=0, score1=0, score2=0, score3=0, score4=0, score5=0, small=0;
getscore (score1, score2, score3, score4, score5);
calcAverage (average, score1, score2, score3, score4, score5, small);
getch();
return 0;
}
void getscore (int &score1, int &score2, int &score3, int &score4, int &score5)
{
cout << "Enter first score: ";
cin >> score1;
cout << "Enter second score: ";
cin >> score2;
cout << "Enter third score: ";
cin >> score3;
cout << "Enter fourth score: ";
cin >> score4;
cout << "Enter fifth score: ";
cin >> score5;
}
int findLowest(int score1, int score2, int score3, int score4, int score5)
{
int small =score1;
if(small>score2)
{
small=score2;
}
if(small>score3)
{
small=score3;
}
if(small>score4)
{
small=score4;
}
if(small>score5)
{
small=score5;
}
return small;
}
void calcAverage (int average, int score1, int score2, int score3, int score4, int score5, int small)
{
average = ((score1 + score2 + score3 + score4 + score5)-small)/4;
cout << average;
}
As soon as I tried to find the average of 100 + 100 + 100 + 100, my average came out to be 125!:@ When you run my program, you will see.