ADVANCE C TUTORIALS
__________________________________________________________________________
Write a C program to accept details of n students (roll number,
name,percentage) using structure. Display details of the
student having maximum percentage.
_____________________________________________________________
#Include <studio.h>
#Include <conio.h>
struct stud{char name [30];
int mark;
}s[5];
void main ()
{
int i ,max ,n;
clrscr();
printf("\n enter name and mark of 3 students\n ");
for (i=0;i<3;i++)
{
printtf ( "Name:");
fflush(stdin);
gets (s[i].name);
fflush(stdin);
printf("marks :");
fflush(stdin);
scanf("%d" ,&s[i].mark);
}
max=s[0].mark;
for(i=0;i<3;i++)
{
if (max<s[i].mark)
{
max=s[i].mark;
n=i;
}
}
printf (" name and mark of the 3 student");
for(i=0;i<3;i++)
{
printf("\n");
printf("%s marks ", s[i].name);
printf(": %d", s[i].mark);
}
printf("\n\n Topper is ");
printf("%s marks ", s[n].name);
printf(": %d",s[n].mark);
getch();
}
0 Comments