Get average and rank it as shown:
sl.no |
average |
grade |
1 |
0-39 |
Fail |
2 |
40-69 |
good |
3 |
70-80 |
Very good |
4 |
81-100 |
Excellent |
C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
int avg;
printf("Enter your average:");
scanf("%d",&avg);
if(avg>=0 && avg<=39)
printf("Poor");
else if(avg>=40 && avg<=69)
printf("Good");
else if(avg>=70 && avg<=80)
printf("Very Good");
else if(avg>=81 && avg<=100)
printf("Excellent");
}
Java Program
import java.util.Scanner;
public class Selection {
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.print("Enter your average:");
int avg = s.nextInt();
if(avg>=0 && avg<=39)
System.out.print("Poor");
else if(avg>=40 && avg<=69)
System.out.print("Good");
else if(avg>=70 && avg<=80)
System.out.print("Very Good");
else if(avg>=81 && avg<=100)
System.out.print("Excellent");
}
}
0 Comments:
Post a Comment