In: Computer Science
write a program that will display student grade if scores is greater than or equal to 70 to display A or else if score is less than or equal to 70 and greater than or equal to 60 display B if scores is less than 60 or greater than 50 display C else display fail.
C program)
#include <stdio.h>
int main(void) {
int score;
printf("Enter score: ");//user input for score
scanf("%d",&score);
if(score>=70)
printf("Grade is : A");
//if score in between 60 to 70 print B
else if(score>=60 && score<70)
printf("Grade is : B");
//if score in between 50 to 60 print B
else if(score>50 && score<60)
printf("Grade is : C");
//else print fail
else
printf("Fail");
return 0;
}
Output::
If you want program in JAVA refer below code:
import java.util.Scanner;//import Scanner
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);//creates object of class Scanner
System.out.print("Enter score:");//user input for score
int score = sc.nextInt();
//if score >= 70 print A
if(score>=70)
System.out.print("Grade is : A");
//if score in between 60 to 70 print B
else if(score>=60 && score<70)
System.out.print("Grade is : B");
//if score in between 50 to 60 print B
else if(score>50 && score<60)
System.out.print("Grade is : C");
//else print fail
else
System.out.print("Fail");
}
}
Output::
Note:: if any queries please comment else thumbs up!