Wrote this code, but can\'t seem to figure out why it won\'t compile. I keep get
ID: 654202 • Letter: W
Question
Wrote this code, but can't seem to figure out why it won't compile. I keep getting the same error.
#include <iostream>
#include <iomanip>
using namespace std;
void getScore(int scores)
{
cout << "Enter a test score: ";
cin >> scores;
while (scores < 0 || scores > 100)
{
cout << "Enter a valid test score." << endl;
cin >> scores;
}
}
void calcAverage(int scores[])
{
int lowest;
lowest = findLowest(scores);
int total = 0;
double average;
for (int i = 0; i < 5; i++)
{
if (scores[i] != lowest)
total = total + scores[i];
}
average = total / 5;
cout << "The average of the test scores is: " << fixed << setprecision(2) << average << endl;
}
int findLowest(int scores[])
{
int low = scores[0];
for (int i = 0; i < 5; i++)
{
if (scores[i] < low)
low = scores[i];
}
return low;
}
int main()
{
int scores[5];
for (int i = 0; i < 5; i++)
{
getScore(scores[i]);
}
calcAverage(scores);
return 0;
}
Explanation / Answer
Dear You are importing the headerfile in C it is required to include the file with .h extension please try for that it will certaily run.
which kind of error it is showing.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.