Input average marks of students and show the grade as the following conditions - C

Q. Write a program to input average marks of students and show the grade as the following conditions .
marks               Grade
0-39                     F
40-49                   D
50-59                   C
60-79                   B
80-100                 A 

#BIT_FirstSem_2017_5No_8Marks_Solution
==> Code goes like this :

#include<stdio.h>
int main()
{
    float marks;
    printf("\n Enter average marks : ");
    scanf("%f",&marks);
    if(marks>=80 && marks<=100)
    {
        printf("\n A Grade");
    }
    else if(marks>=60 && marks<=79)
    {
        printf("\n B Grade");
    }
    else if(marks>=50 && marks <=59)
    {
        printf("\n C Grade");
    }
    else if(marks>=40 && marks<=49)
    {
        printf("\n D Grade");
    }
    else if(marks>=0 && marks<=39)
    {
        printf("\n F Grade");
    }
    else
    {
        printf("\n Invalid input");
    }
    return 0;
}

Output:
 











If you are using Turbo C++ IDE, then use conio.h in link section after stdio.h
and use getch(); to hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you
Share on Google Plus

About Nepali Xoro

Interested in Information Technology, Spreading Knowledge for Nepalease IT Students."Loves Traveling", Listen Music and Surfing web.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment