Accept student details with 5 subject using array
Accept student roll no.,name,age,subject name and marks of 5 subject using array
#include"stdio.h"
#include"conio.h"
void main()
{ float ans;
int mark[5],i,roll,age;
char name[5][20],sname[20];
clrscr();
printf("\nEnter the Roll number of student=");
scanf("%d",&roll);
fflush(stdin);
printf("\nEnter the name of student=");
gets(sname);
printf("\nEnter the age of student=");
scanf("%d",&age);
for(i=0;i<5;i++)
{
printf("\n\nEnter the %d subject name=",i+1);
fflush(stdin);
gets(name[i]);
printf("\n\nEnter the marks of %s out of 100 is=",name[i]);
scanf("%d",&mark[i]);
ans=ans+mark[i];
}
printf("\n\n\n *********** Result ************");
ans=ans/5;
printf("\n\n The percentage of %s is =%.2f%",sname,ans);
if(ans>95)
{
printf("\n\n!!!! Congratulation !!!! You scored A++ Grade.");
}
else if(ans<=95&&ans>80)
{
printf("\n\nYou scored A+ Grade.");
}
else if(ans<=80&&ans>70)
{
printf("\n\nYou scored A Grade.");
}
else if(ans<=70&&ans>60)
{
printf("\n\nYou scored B++ Grade.");
}
else if(ans<=60&&ans>50)
{
printf("\n\nYou scored B Grade.");
}
else if(ans<=50&&ans>40)
{
printf("\n\nYou scored only Pass Grade.");
}
else
{
printf("\n\n***** Sorry You are Fail......");
}
getch();
}
#include"conio.h"
void main()
{ float ans;
int mark[5],i,roll,age;
char name[5][20],sname[20];
clrscr();
printf("\nEnter the Roll number of student=");
scanf("%d",&roll);
fflush(stdin);
printf("\nEnter the name of student=");
gets(sname);
printf("\nEnter the age of student=");
scanf("%d",&age);
for(i=0;i<5;i++)
{
printf("\n\nEnter the %d subject name=",i+1);
fflush(stdin);
gets(name[i]);
printf("\n\nEnter the marks of %s out of 100 is=",name[i]);
scanf("%d",&mark[i]);
ans=ans+mark[i];
}
printf("\n\n\n *********** Result ************");
ans=ans/5;
printf("\n\n The percentage of %s is =%.2f%",sname,ans);
if(ans>95)
{
printf("\n\n!!!! Congratulation !!!! You scored A++ Grade.");
}
else if(ans<=95&&ans>80)
{
printf("\n\nYou scored A+ Grade.");
}
else if(ans<=80&&ans>70)
{
printf("\n\nYou scored A Grade.");
}
else if(ans<=70&&ans>60)
{
printf("\n\nYou scored B++ Grade.");
}
else if(ans<=60&&ans>50)
{
printf("\n\nYou scored B Grade.");
}
else if(ans<=50&&ans>40)
{
printf("\n\nYou scored only Pass Grade.");
}
else
{
printf("\n\n***** Sorry You are Fail......");
}
getch();
}