I am learning C functions and trying to write a simple script that outputs a lettergrade depending on the number the user inputs. Yet I am getting the following error and I can't figure out where I'm lacking...
102809.c: In function ‘function_points’:
102809.c:44: error: ‘lettergrade’ redeclared as different kind of symbol
102809.c:41: error: previous definition of ‘lettergrade’ was here
102809.c:47: error: ‘A’ undeclared (first use in this function)
102809.c:47: error: (Each undeclared identifier is reported only once
102809.c:47: error: for each function it appears in.)
102809.c:49: error: syntax error before ‘lettergrade’
If you could please provide guidance, I would appreciate it. I am comparing this script to a simple C function script and they look similar :(
#include<stdio.h>
#include<stdlib.h>
//prototype
int function_points (char);
int main (void)
{
//use a do or while loop to continue asking for user input, asking user to input test score.
//0 = quit
int points; //this is student's points, we call this via scanf
int counter; //our counter variable to increase loop
char lettergrade;
counter = 0;
do {
printf("Enter the student's points: (0 to quit): ");
scanf("%d", &points);
printf("%d points = %c grade \n", points, function_points(lettergrade)); //declare function
counter++;
} while (points != 0);
//counter --;
printf("Press any key to continue...");
getchar();
getchar();
return 0;
}
//function definition
int function_points (char lettergrade)
{
int points;
char lettergrade;
if (points < 90 && points > 100)
lettergrade = A;
else if (points < 80 && points > 89
lettergrade = B;
else if (points < 70 && points > 79
lettergrade = C;
else if (point < 60 && point > 69)
lettergrade = D;
else
{
lettergrade = F;
}
return lettergrade;
}