#include using namespace std; const int TOTALYEARS = 100; int findCurrent (ageFr
ID: 3628170 • Letter: #
Question
#include
using namespace std;
const int TOTALYEARS = 100;
int findCurrent (ageFrequency, )
int findCounter ( , )
int main()
{
int ageFrequency[TOTALYEARS]; // array with 100 elements.
int pos; // index to the array.
int findAge
int currentAge; // contains current the age .
int ageCounter; // contains age
// Read in the values into the array
cout << "Please input an age from 1 to 100. input -99 to stop" << endl;
cin >> currentAge;
while (currentAge != -99)
{
ageFrequency[currentAge - 1] = ageFrequency[currentAge - 1] + 1;
cout << "Please input an age from 1 to 100. input -99 to stop" << endl;
cin >> currentAge;
}
cout << "The number of people " << currentAge << " is " << ageCounter << endl;
currentAge = findCurrent (grades, numberOfGrades); // call to the function that calculates highest grade
ageCounter = findCounter ( , ); //
return 0;
}
//****************************************************************************
// findCurrent
//
// task: This function receives an array of integers and its size.
// It finds and returns the current age of the numbers in the array
// data in: array of int numbers
// data returned: current age of the numbers in the array
//
//****************************************************************************
int findCurrent ( array, int size)
{
for (int pos = 0; pos < TOTALYEARS; pos++)
// pos acts as the array subscript
{
ageFrequency[pos] = 0;
}
return ( ); //returns the
}
//****************************************************************************
// findCounter
//
// task: This function receives an array of integers and its size.
// It finds and returns the Count value of the numbers in
// the array
// data in: array of int numbers
// data returned: count value of the numbers in the array
//
//****************************************************************************
int findCounter ( array, int )
{
for (int ageCounter = 0; ageCounter
if (ageFrequency[ageCounter] > 0)
cout << "The number of people " << ageCounter + 1 << " years old is " << ageFrequency[ageCounter] << endl;
return ( ); //returns the
}
Explanation / Answer
#include using namespace std; const int TOTALYEARS = 100; int main() { int ageFrequency[TOTALYEARS]; // array with 100 elements. int pos=0; // index to the array. int findAge; int currentAge; // contains current the age . int ageCounter[TOTALYEARS]; // contains age for(int i=0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.