Grade Calculator in C
Level 3173 keystrokes
Converts a numeric score to a letter grade using if-else statements.
C code
// The score to convert1int score = 85;// A char holds one letter; it gets a value in exactly one branch below2char grade;// Tests run from the top; 85 >= 90 is false3if (score >= 90) grade = 'A';// Reached only below 90, so this means 80–89; 85 matches, grade = 'B'4else if (score >= 80) grade = 'B';// 70–79 would give 'C'; skipped because a branch already matched5else if (score >= 70) grade = 'C';// Anything below 70 gets 'F' (there is no D in this scheme)6else grade = 'F';// %c prints a single char: Grade: B7printf("Grade: %c", grade);Output
Grade: B
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C code and how often they appear.
'× 8=× 8;× 7(× 4)× 4>× 3"× 2,× 1:× 1%× 1