Expert Q&A; Done 12+13 (2 parts) inside an array of integers Question 12 (fumcti
ID: 3723824 • Letter: E
Question
Expert Q&A; Done 12+13 (2 parts) inside an array of integers Question 12 (fumction pretotype/definition-20 points) Write a function findLowsoores that searches an amay of integers for the wumiber of os A score is a score less than a given threshold. The function takes three anguments realiat, an array of integers to be searched 2. size, the number of elements in the array 3. threshold, an integer The function returns the total number of scores less than threshold in the armay. Question 13 (Rest of the program- 20 points) The program creates and populates an integer array of 5 exam scores with entries from the user. Afer calculating the total number of scores in the array that are "low".i.e. less than 50, the program pints screen whether the performance was AboveAverage or OnOrBlelow Average. Performance is OnOrBelowAverage if more than half of the class has low" scores and OnOrBelow Average, For example, if the array contains 92, 89, 65, 84, 35, the program should print AboveAverage Performance OLUTIONExplanation / Answer
Answer 12:
//function definition
int findLowScores(int scoresList[], int size, int threshold)
{
int count = 0;
for(int i = 0 ; i < size; i++)
{
if(scoresList[i] < threshold)
count++;
}
return count;
}
==========================
Answer 13: Using the code from Answer 12
#include <iostream>
using namespace std;
//function prototype
int findLowScores(int scoresList[], int size, int threshold);
int main()
{
int size = 5;
int scoresList[5];
int lowCount;
int threshold = 50;
cout << "Enter the 5 scores: " << endl;
for(int i = 0; i < size; i++)
{
cout << "score #" << (i+1) << ": ";
cin >> scoresList[i];
}
cout << endl;
lowCount = findLowScores(scoresList, size, threshold);
if(lowCount >= size/2)
cout << "OnOrBelowAverage Performance" << endl;
else
cout << "AboveAverage Performance" << endl;
}
//function definition
int findLowScores(int scoresList[], int size, int threshold)
{
int count = 0;
for(int i = 0 ; i < size; i++)
{
if(scoresList[i] < threshold)
count++;
}
return count;
}
======output=======
Enter the 5 scores:
score #1: 92
score #2: 89
score #3: 65
score #4: 84
score #5: 35
AboveAverage Performance
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.