Saturday, 5 March 2022

7. Take marks from the user and print grade

 7. Take marks from the user and print grade accordingly( >=75 marks – Distinction, <75 and >=60 marks – First, <60 and >=50 – Second, <50 and >=35 – Pass, <35 – Fail) using if … else if….else statement and also by using logical operators).



#include<stdio.h>
#include<conio.h>

void main()
{
    int mark;
    clrscr();

    printf("enter your marks: ");
    scanf("%d",&mark);

    if(mark>=75)
    {
        printf("\ndistinction");
    }
    else
    {
        if(mark<75 && mark>=60)
        {
            printf("\nfirst");
        }
        else
        {
            if(mark<60 && mark>=50)
            {
                printf("\nsecond");
            }
            else
            {
                if(mark<50 && mark>=35)
                {
                    printf("\npass");
                }
                else
                {
                    printf("\nfail");
                }
            }
        }
    }
    getch();
}

/*   output:

enter your marks: 64

first

*/

No comments:

Post a Comment

python programs

1. sum of two number