I am learning the C programming language. I am doing homework with C programming language. But I am getting a problem. The result is not printing. I am using format specifier %s. Here is my code below. Please have a look.
#include <stdio.h>
int gradeCalculation(int marks) {
switch (marks) {
case 0 ... 49:
return 'F';
break;
case 50 ... 59:
return 'D';
break;
case 60 ... 69:
return 'C';
break;
case 70 ... 79:
return 'B';
break;
case 80 ... 89:
return 'A';
break;
case 90 ... 100:
return 'A+';
break;
default:
return 'Marks is not valid!';
}
}
int main() {
int marks;
printf("Marks: ");
scanf("%d", &marks);
printf("Grade: %s\n", gradeCalculation(marks));
return 0;
}
How to solve my problem? What specifier should I use to get the expected result?
Aucun commentaire:
Enregistrer un commentaire