#include<iostream> #include<fstream> #include<stdlib.h>//fortheexit()function us
ID: 3656415 • Letter: #
Question
#include<iostream>
#include<fstream>
#include<stdlib.h>//fortheexit()function
usingnamespacestd;
//functionprototypes
voidReadInScores(intscores[],int&howMany);
floatFindAverage(intscores[],inthowMany);
voidPrintScores(intscores[],inthowMany);
intmain()
{
//varibledeclaration
constintMAX_SCORES=30;//thearrayhasatmost30entries
intscores[MAX_SCORES];//anarrayoftestscoreswith30entries
inthowMany;//theactualsizeofthearray
floataverageScore;//theaverageofthescoresarray
//activatethefunctiontoreadthescores
ReadInScores(scores,howMany);
//activatethefunctiontoprintthescores
PrintScores(scores,howMany);
//PlaceyouractivationstatementforFindAverage()here
//averageScorewillbeassignedfromFindAverage
Place your activation statement for FindAverage() here averageScore will be assigned from FindAverage REMEMBER: average is float and make sure NOT to do interger expression.
cout<<"Averagescoreis:"<<averageScore<<endl;
return0;
}
//Function:ReadInScores()
//Thisfunctionreadsasetofscoresfromstandardinput.
//Firstthenumberofscoresisread,thenthescores.
voidReadInScores(intscores[],int&howMany)
{
//readthenumberofscoresfirst
//thenreadthescoresintoarray
// The input of the first line is the number of scores, // and the rest of the input are scores. // Read the number of scores first then read the scores into array // Do NOT add any OUTPUT statement here!!
}
//YourPrintScores()function
//Thisfunctionispassedanarrayofscoresandthe
//numberofscores.Itprintsthescores.
voidPrintScores(intscores[],inthowMany)
{
//printscoresinarray
//numberofscoresinthearrayishowMany
for(inti=0;i<howMany;i++)
cout<<scores[i]<<endl;
return;
}
//PlaceyourFindAverage()functiondefinitionhere
//Function:FindAverage()
//Thisfunctionispassedanarrayofscoresandthe
//numberofscores.Itreturnstheaverageofthescores.
Place your FindAverage()function definition here Function: FindAverage() This function is passed an array of scores and the number of scores. It returns the average of the scores.
Explanation / Answer
#include #include #include//fortheexit()function using namespace std; //functionprototypes void ReadInScores(int scores[],int&howMany); float FindAverage(int scores[],int howMany); void PrintScores(int scores[],int howMany); int main() { //varibledeclaration const int MAX_SCORES=30;//thearrayhasatmost30entries int scores[MAX_SCORES];//anarrayoftestscoreswith30entries int howMany;//theactualsizeofthearray float averageScore;//theaverageofthescoresarray //activatethefunctiontoreadthescores ReadInScores(scores,howMany); //activatethefunctiontoprintthescores PrintScores(scores,howMany); //PlaceyouractivationstatementforFindAverage()here averageScore=FindAverage(scores,howMany); //averageScorewillbeassignedfromFindAverage coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.