#include <iostream>
#include <ctime>
#include <cstdlib>
usingnamespace std;
void populateArray(int arr[], int size);
bool fail(int grade);
int main()
{
constint ARRAY_SIZE = 100;
int quizzes[ARRAY_SIZE];
int failed = 0;
populateArray(quizzes, ARRAY_SIZE);
for(int i = 1; i <= ARRAY_SIZE; i++){
if(fail(quizzes[i])){
cout << "Student at element " << i << " scored " << quizzes[i] << ". That is a passing grade." << endl;
} else{
failed++;
cout << "Student at element " << i << " scored " << quizzes[i] << ". That is not a passing grade." << endl;
}
}
cout << endl;
cout << failed << " people failed." << endl;
return 0;
}
void populateArray(int arr[], int size)
{
srand(time(0));
for(int i = 0; i < size; i++){
arr[i] = rand() % 101;
}
}
bool fail(int grade)
{
if(grade < 70)
returnfalse;
elsereturntrue;
}
Okay, first thing first. Your function prototype is missing the array name.
void PopulateArray(int[], int size)
Next if(Fail)true is invalid. The way you would test if it's true or false is by if(Fail()) because its returning either true or false.
Next. failed =+ 1; is setting failed equal to positive 1. I'm assuming you're trying to increment it every time, you do that like this failed += 1. Or even simpler just failed++;
Then everything else just kind of confused me.
That's why I posted my version of your program. Hopefully it can help you. If you need me to clarify anything don't hesitate to ask. I'm new to programming too ^_^
You know what I totally scrambled alot of the description and the code since i rushed it in class then just tried to add things to make it work causing more problems. Thank you for your help i see where i had things backwards and completely off which was why my output failed. The Fail bool was just me putting something there to show what i kind of wanted I had no idea of how to actually implement it, so i thank you for that to and the great explanation :).