Hi guys, I've got the code all written but there are a ton of runtime errors that need to be fixed, mainly with calculations and inputting data into the array. I also need to use pointers when referencing the scores array, and I cannot for the life of me get the pointers concept down! Here is the code I have... This is an extremely important assignment that is due at midnight tonight, so any help would be really great!
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int menu();
void heading(void);
double getgrades(double s[]);
void showgrades(double s[], int count);
double changegrade(double s[], int count);
double findgrades(double s[], int count);
void message(char msg[]);
void show(double s[], int count);
int menuerror(int min, int max, char prompt[]);
int prompt(char msg[]);
int quit(void);
/* ================================================================== */
// ** Functions **
int main()
{
int TRUE = 1;
int FALSE = 0;
int select, end = TRUE;
int count=0;
double scores[101];
do
{
select = menu();
switch (select)
{
case 1: getgrades(scores); break;
case 2: showgrades(scores, count); break;
case 3: changegrade(scores, count); break;
case 4: findgrades(scores, count); break;
case 5: end = quit(); break;
default: message("\n\nPlease make a selection between 1 and 5.\a");
}
}
while (end);
return 0;
}
/* ================================================================ */
int menu()
{
int choice;
system("cls");
printf("Grade Score Database\n\n");
printf("1 = Get Grades\n");
printf("2 = Show Grades\n");
printf("3 = Change Grade\n");
printf("4 = Find Grade\n");
printf("5 = Quit\n\n");
choice = menuerror(1, 5, "Enter your selection");
return(choice);
}
/* ================================================================ */
void heading()
{
system("cls");
printf("Grade Score Database\n\n\n");
return;
}
/* ================================================================ */
double getgrades(double *s)
{
double scores[101];
int z, count=0;
for (z = 1; z < 101; z++)
count += 1;
{
printf("Enter a grade, or 0 to quit: ");
scanf("%d", &scores[z]);
}
while (&scores[z] != 0);
return(count);
}
/* ================================================================ */
void showgrades(double *s, int count)
{
int z;
double scores[101];
system("cls");
printf("Score Report\n\n");
printf("_Position________Grade_\n\n");
for (z = 1; z < 101; z++)
{
printf(" %2d%2lf\n\n", z, scores[z]);
}
printf("Press ENTER to return to the Main Menu...");
getchar();
}
/* ================================================================ */
double changegrade(double *s, int count)
{
int z;
double scores[101];
for (z = 1; z < 101; z++)
{
printf("Enter grade position to edit, or 0 if no changes: ");
scanf("%d", &z);
printf("Enter new grade for position %d: ", z);
scanf("%d", &*(scores+z));
}
while (*(scores+z) != 0);
return 0;
}
/* ================================================================ */
double findgrades(double *s, int count)
{
int z, low, high;
double scores[101];
printf("Enter lowest grade to locate: \n");
scanf("%d", &low);
printf("Enter highest grade to locate: \n");
scanf("%d", &high);
printf("The following grades are within the specified range: \n\n");
for (z = 1; z < 101; z++)
if (scores[z] > low || scores[z] < high)
{
show(scores, count);
}
printf("Press ENTER to return to the Main Menu...");
getchar();
return 0;
}
/* ================================================================ */
void show (double *s, int count)
{
int z;
double scores[101];
for (z = 1; z < 101; z++) printf ("%4d", scores[z]);
printf ("\n");
}
/* ================================================================ */
void message(char msg[])
{
printf("%s\n\n", msg);
}
/* ================================================================ */
int menuerror(int min, int max, char item[])
{
int z;
printf("%s from %d to %d: ", item, min, max);
scanf("%d%*c", &z);
while (z < min || z > max)
{
message("\nError in range. Press Enter to continue.\a");
printf("%s from %d to %d: ", item, min, max);
scanf("%d%*c", &z);
}
return(z);
}
/* ================================================================ */
int prompt(char msg[])
{
int z;
do
{
printf("%s (Y/N)? ", msg);
z = toupper(getchar());
if (z != 'Y' && z != 'N') printf("\nError, please enter Y or N only.\n");
}
while (z != 'Y' && z != 'N');
return(z);
}
/* ================================================================ */
int quit()
{
int TRUE = 1;
int FALSE = 0;
int z, end = TRUE;
z = prompt("\nEnd program\a");
if (z == 'Y')
{
system("cls");
message("\nGrade Score Database Closed Succesfully.");
end = FALSE;
}
return(end);
}
/* ================================================================ */