The marks obtained by a student in 5 different subjects are input through the keyboard. The students gets a division as per the following rules: Percentage above or equal to 60- First division . Percentage between 50 and 59- Second division. Percentage between 40 and 49- Third division. percentage less than 40- Fail. Write a program to calculate the division obtained by the student using logical operator.

 #include<stdio.h>

void main()

{

//ProgramWithHarsh//

float eng,hindi,maths,phy,chem,percent;

printf("\nEnter engish marks: ");

scanf("%f",&eng);

printf("\nEnter hindi marks: ");

scanf("%f",&hindi);

printf("\nEnter maths marks: ");

scanf("%f",&maths);

printf("\nEnter physics marks: ");

scanf("%f",&phy);

printf("\nEnter chemistry marks: ");

scanf("%f",&chem);

percent=(eng+hindi+maths+phy+chem)*100/500;

printf("\nPercentage=%f",percent);

if(percent>=60)

printf("\nFirst division");

    

if((percent>=50)&&(percent<60))

printf("\nSecond division");

if((percent>=40)&&(percent<50))

printf("\nThird division");

if(percent<40)

printf("\nFail");

}

The output will be

Post a Comment (0)
Previous Post Next Post