160k views
2 votes
Write a program to insert student grade and print the following

90 -> A
> 80 -> B
> 70 -> C
> 60 -> D
< 60 -> "Fail"

User Andriy
by
5.6k points

1 Answer

6 votes

Answer:

The answer is the program, in the explanation

Step-by-step explanation:

I am going to write a C program.

int main(){

int grade = -1; /*The grade will be read to this variable*/

/*This loop will keep repeating until a valid grade is inserted*/

while(grade < 0 || grade > 100){

printf("Insert the student's grade: %n");

scanf("%d", &grade);

}

/*The conditional according to the grade value*/

if (grade >= 90){

printf("Your grade is A\\");

}

else if (grade >= 80 && grade < 90){

printf("Your grade is B\\");

}

else if (grade >= 70 && grade < 80){

printf("Your grade is C\\");

}

else if (grade >= 60 && grade < 70){

printf("Your grade is D\\");

}

else{

printf("You got a failling grade\\");

}

return 0;

}

User Jinkal
by
5.4k points