Given below is a c program to check student result using if else condition.
Condition for declaring a student as pass or fail is given below:
- For, percentage >= 40 : Pass
- For, percentage < 40 : Fail
C program to check whether a student is pass or fail:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
#include<stdio.h> #include<conio.h> void main() { int percentage; clrscr(); printf("Enter Your Percentage: "); scanf("%d",&percentage); if(percentage<0 || percentage>100) { printf("Wrong Entry"); } else if(percentage<40) { printf("Grade F \nSorry You're Fail! "); } else if(percentage>=40 && percentage<60) { printf("Grade D"); } else if(percentage>=60 && percentage<70) { printf("Grade C"); } else if(percentage>=70 && percentage<80) { printf("Grade B"); } else if(percentage>=80 && percentage<90) { printf("Grade A"); } else { printf("Grade E \nYou're Excellent!"); } getch(); } |
Output: