C program to find grade of student by using nested else-if statement
Problem Description
This program take input as your number then show your grade.
Problem Solution
1. enter your marks as input.
2. then check your marks with 'If' block's condition. if it satisfied then show your grade as output.
3. if it not satisfied then it checks with all else-if block's condition repeatedly.
4. print the grade according to your given marks as input and exit.
Program codes:-
#include<stdio.h>main()
{
int n;
printf("\n enter the marks:");
scanf("%d",&n);
if(n>89)
printf("O");
else if(n>79)
printf("E");
else if(n>69)
printf("A");
else if(n>59)
printf("B");
else if(n>49)
printf("C");
else if(n>39)
printf("D");
else
printf("F");
}
Program explanation:-
.
2. then your input checks with 'if' block's condition. if it satisfied then it directly show the output.
3. if it doesn't satisfied then it goes to 'else-if' block's condition. if it satisfied with any else-if blocks then it show the grade as output.
4.if it doesn't satisfied with any else-if block's condition then at last it goes to else block's condition.
Comments
Post a Comment
please subscribe my blog and let me suggest how I improve this site