Hey guys.
Im so close to finishing this hw but im stumped on this part.
Im trying to add a letter grade to the array element depending on what exam score is in the condition of the if statement. Now, it all compiles ok how it is but when I run it, it only prints the first grade for the first result and
then duplicates this all the way down the list.
Here is my code:
I think i have the i++ in the wrong place, or am I loopingCode:// function to calculate the letter grade for each student
void calculateGrade ( char letterGrades[], double examScores[], const int SIZE ) {
for ( int i = 0; i < SIZE; ) {
for ( int j = 0; j < SIZE; j++ ) {
if (( examScores[ i ] >= 90 ) && ( examScores[ i ] <= 100 )) {
letterGrades[ j ] = 'A';
}
else if (( examScores[ i ] >= 80 ) && ( examScores[ i ] <= 89 )) {
letterGrades[ j ] = 'B';
}
else if (( examScores[ i ] >= 70 ) && ( examScores[ i ] <= 79 )) {
letterGrades[ j ] = 'C';
}
else if (( examScores[ i ] >= 60 ) && ( examScores[ i ] <= 69 )) {
letterGrades[ j ] = 'D';
}
else if (( examScores[ i ] >= 0 ) && ( examScores[ i ] <= 50 )) {
letterGrades[ j ] = 'F';
}
}
i++;
}
}
inccorectly? Btw both arrays were initlized to empty before this function was called.
Basically an output would be:
When it should always be diff for each one pending the value - so it is deffinatly this function I am having the logical error - any help really appriciated.Code:letter grades for exam:
A
A
A
A
A
A
A
A
A
A