main()
{
int m[5],i,p,total,sno;
char sname[20],g[5];
float avg;
char res[20],grade;
char subname[5][30]={"Computer Organisation","Business Process","Problem Solving","Accountancy","Data Structures"};
p=0;total=0;
printf("Enter the student details...\n\n");
printf("Enter the Student Name : ");
scanf("%s",sname);
printf("Enter the Student Number : ");
scanf("%d",&sno);
for(i=0;i<5;i++)
{
printf("Enter the %s mark : ",subname[i]);
scanf("%d",&m[i]);
if (m[i]>=80)
{
if (p<1)
{
grade='O';
p=1;
}
g[i]='O';
}
else if(m[i]>=70)
{
if (p<2)
{
grade='A';
p=2;
}
g[i]='A';
}
else if(m[i]>=60)
{
if (p<3)
{
grade='B';
p=3;
}
g[i]='B';
}
else if(m[i]>=50)
{
if (p<4)
{
grade='C';
p=4;
}
g[i]='C';
}
else
{
grade='D';
p=5;
g[i]='D';
}
total=total+m[i];
}
avg=(float)total/5;
printf("\n\n\t\t\tSTUDENT MARKLIST\n");
printf("----------------------------------------------------------------------------");
printf("\n\nSTUDENT NAME : %s",sname);
printf("\nROLL NUMBER : %d",sno);
printf("\n\n");
printf("----------------------------------------------------------------------------");
printf("\n\t\tSUBJECT\t\tMARKS\t GRADE\n");
printf("----------------------------------------------------------------------------");
printf("\n");
for(i=0;i<5;i++)
printf("%25s \t%d\t %c\n",subname[i],m[i],g[i]);
printf("\n");
if (grade=='O')
strcpy(res,"OUTSTANDING");
else if (grade=='A')
strcpy(res,"FIRST CLASS");
else if (grade=='B')
strcpy(res,"SECOND CLASS");
else if (grade=='C')
strcpy(res,"THIRD CLASS");
else
strcpy(res,"FAIL");
printf("----------------------------------------------------------------------------");
printf("\nTOTAL : %d",total);
printf("\nAVERAGE : %f",avg);
printf("\nGRADE : %c",grade);
printf("\nRESULT : %s\n\n",res);
printf("----------------------------------------------------------------------------\n\n");
}
No comments:
Post a Comment