QUOTE(wartech @ 2 Aug, 2007 - 07:29 PM)

Hey Everyone,
I need to convert the number grade to a letter grade using a function not if statements as I have done. I am a little confused about doing this. The furthest I have gotten is declaring it. Below that is my code using a for loop and if statements to convert the number grade to a letter, but I need a function to do this. Thanks for your time!
CODE
//FUNCTIONS
int num_letter(int x); //Is this the correct declaration?
//OUTPUT
for (i=1; i < count; i++)
{
grades[count] += i;
if (grades[i] >= 91)
{
lgrade[i] = 'A';
passing += 1;
}
else
if (grades[i] >= 81)
{
lgrade[i] = 'B';
passing += 1;
}
else
if (grades[i] >= 71)
{
lgrade[i] = 'C';
passing +=1;
}
else
if (grades[i] >= 61)
{
lgrade[i] = 'D';
passing +=1;
}
else
if (grades[i] <= 60)
{
lgrade[i] = 'F';
failing +=1;
}
}
First off you would have to test for a higher score and a lower score: if (student_score < 90 && student_score > 79), then return this grade. Of course the first test would only have scores above or equal to 90: if (student_score >= 90), then return this grade, and the last test would be only scores below or equal to 62: if (student_score <= 62), then return this grade.
Now to write a function that would return the grade from the student's score. Here is a prototype: char display_student_grades( int student_score ); Now see if you can finsh it. Remember that this function has a return type of char( in this case a letter grade like 'A' ), so in each test of the actual student's score, this function has to return a value of char that matches with the int student_score.
Hope that helps!
barnwillyb