if statement for grade students C programing.
Tue Nov 15 2022 12:33:06 GMT+0000 (Coordinated Universal Time)
Saved by
@Mohamedshariif
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <stdlib.h>
/*Write a code that will read a student’s score on a test and determine the grade in letter (A is 90+, B is between 80 and 89, C is 70 and 79, D is 60 and 69, F is less than 60)
The output of the code should look on the computer monitor as follows:
(Hint: grade is a single letter. Use data type character when you first declare it in the program)*/
int main() {
int grade;
char lgrade;
printf("please enter your grade");
scanf("%d", &grade);
if(grade>=90)
lgrade='A';
else if(grade>=80 &&grade<90)
lgrade='B';
else if(grade>=70 && grade<80);
lgrade='C';
else if(grade>=60 && grade<70)
lgrade='D';
else
lgrade='F';
printf("Student scored %d on the exam and his/her grade is %c",grade,lgrade);
return 0;
}
content_copyCOPY
Comments