Alright I am supposed to write code that allows the user to enter inputs for the array grade that are counted as they are read. The program is to display the average and sum of the array. Also, the program is to display the numbers in the array with an * if they are below the average along with the letter grade (i.e. 92 is A).
I have wrote the parts of the code that I am familiar with. The two things that my text does not cover, is how to establish an array and its size through user input. And how to add the * and letter grade to the displayed list after the computations are done.
Here is what code I do have:
Code:
#include <stdio.h>
#pragma warning (disable :4996)
double findSum(double[], int);
double findAvg(double [], int);
int main()
{
#define NUMELS
double grades;
double average, sum;
printf("Enter the grades, when finished enter a negative number: ");
scanf("%f", &grades[]);
average = findAvg(grades[], int);
sum = findSum(grades[], int);
printf("The sum of the grades is %f", sum);
printf("The average of the grades is %f", average);
return 0;
}
double findAvg(double grades[], int)
{
int i;
double sumnums = 0.0;
for (i = 0; i < NUMELS; i++)
sumnums = sumnums + grades[i];
return (sumnums/NUMELS); /*calculate and return average*/
}
double findSum(double grades[], int)
{
int i;
double sumnums = 0.0;
for (i = 0; i < NUMELS; i++)
sumnums = sumnums + grades[i];
return (sumnums); /*reutrn the sum*/
}