Code Box
-------------------------------------
/*program to enter marks of a student in five subjects and find grade as
=> average>90 A+
=> average<90 and average<75 A
=> average<75 and average >60 B
=> average<60 and average >50 C
=> average<50 D
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int m1,m2,m3,m4,m5; // marks in five subjects
float avg;
clrscr();
/* Accepting marks of five subjects */
printf("\nEnter marks(max. 100):");
printf("\nEnglish:");
scanf("%d",&m1);
printf("\nMaths:");
scanf("%d",&m2);
printf("\nPhysics:");
scanf("%d",&m3);
printf("\nChemistry:");
scanf("%d",&m4);
printf("\nBiology:");
scanf("%d",&m5);
/*Calculation of average */
avg=(m1+m2+m3+m4+m5)/5;
/*Percentage */
printf("\nPercentage: %.3f%",avg);
/*Selection of grade */
if(avg>=90)
{
printf("\nGrade : A+");
}
else if(avg<90 && avg>=75)
{
printf("\nGrade : A");
}
else if(avg<75 && avg>=60)
{
printf("\nGrade : B");
}else if(avg<60 && avg>=50)
{
printf("\nGrade : C");
}else if(avg<50)
{
printf("\nGrade : D");
}
getch();
}
No comments:
Post a Comment