Trying to create a program that has arrays to take grade entered and spit it back in the same order with a mark of A, B P U if below 50%, then calcs the average, the highest, and lowest grade
#include <iostream>
usingnamespace std;
void printElements(int*, int);
void enterElements(int*, int);
double calc_average(int arr[], int n);
int main()
{
int n = 0;
int arr[10];
enterElements(arr, n);
calc_average(arr, n);
return 0;
}
void enterElements(int arr[], int n)
{
do (arr[n] != 0)
{
for (int i = 0; i < n; i++){
cout << "Enter Result " << i + 1 << " (or -1 if no more result): ";
cin >> arr[n];
// cout << endl;
if (arr[n] == -1)
{
break;
}
if (arr[n] > 100)
{
i--;
cout << "Invalid Input!" << endl;
}
}
}
printElements(arr, n);
}
double calc_average(int arr[], int n){
double avg;
int sum;
int i;
sum = 0;
for (i = 0; i < n; i++)
{
sum += arr[n];
}
avg = sum / (double)n;
cout << "The average of the results = " << avg << endl;
return avg;
}
void printElements(int arr[], int n)
{
int i = 0;
cout << "\nSummary of the results: \n";
for (i = 0; i < n; i++)
{
cout << "Result " << i + 1 << " is ";
cout << arr[i];
cout << endl;
}
}