I worte this program to convert the examination scores to letter grades but the output isn't coming out correctly. Here's what i have:
This is the output:Code:
#include <stdio.h>
#include <stdlib.h>
int getGradeValue(int, int);
//char letterGrade(int*, int, int, int, int, int, int, int ,int);
void displayGrade( int*, char*);
char makeLetterGrade(char);
int main(void)
{
char letter;
int score;
getGradeValue(0,110);
makeLetterGrade(letter);
displayGrade(&score, &letter);
return EXIT_SUCCESS;
}
int getGradeValue(int mingrade, int maxgrade)
{
int score;
mingrade = 0;
maxgrade = 110;
printf("Enter a value, between 0 and 110, representing the\n");
printf("grade for the examination\n");
scanf("%d", &score);
if (0<= &score <= 110)
{
return(score);
}
else
{
printf("Invalid grade\n");
}
printf("Enter a value, between 0 and 110, representing the\n");
printf("grade for the examination\n");
scanf("%d",&score);
return EXIT_SUCCESS;
}
char makeLetterGrade(char letter)
{
//char letterGrade( int *score, int a_max, int a_min, int b_max, int b_min, int c_max, int c_min, int f_max, int f_min)
int *score, a_max, a_min, b_max, b_min, c_max, c_min, f_max, f_min;
char A;
char B;
char C;
char F;
char X;
printf("Enter max and min grade value for A\n");
scanf("%d %d", &a_max, &a_min);
printf("Enter max and min grade value for B\n");
scanf("%d %d", &b_max, &b_min);
printf("Enter max and min grade value for C\n");
scanf("%d %d", &c_max, &c_min);
printf("Enter max and min grade value for F\n");
scanf("%d %d", &f_max, &f_min);
if (a_max>=*score&&*score>=a_min)
letter = A;
else if (b_max>=*score&&*score>=b_min)
{
letter = B;
}
else if (c_max>=*score&&*score>=c_min)
{
letter = C;
}
else if (f_max>*score&&*score>=f_min)
{
letter = F;
}
else
{
letter = X;
}
return letter;
}
void displayGrade (int *score, char *letter)
{
static int nscore = 0;
int tscore;
printf("The score of %d earned a grade of %c\n", *score, *letter);
printf("%d scores were entered so far.\n", ++nscore );
printf("All scores entered so far total %d\n", tscore);
printf("The average score is %d\n", tscore/nscore);
}
The score of 7106548 earned a grade of
1 scores were entered so far.
All scores entered so far total 85
The average score is 85
The problem is the first line. any suggestions on why i'm getting that value for score and letter? Thanks