Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- struct student
- {
- char name[20];
- char id[10];
- int sem;
- int cource;
- } st;
- int main()
- {
- struct student st[5];
- int i,j,k;
- for(i=0; i<5; i++)
- {
- gets(st[i].name);
- gets(st[i].id);
- scanf("%d",&st[i].sem);
- getchar();
- scanf("%d",&st[i].cource);
- getchar();
- }
- j=st[0].sem;
- for(i=0; i<5; i++)
- {
- if(j<st[i].sem)
- {
- j=st[i].sem;
- }
- }
- printf("\nSenior:\n");
- for(i=0; i<5; i++)
- {
- if(j==st[i].sem)
- {
- printf("NAME :%s\n",st[i].name);
- printf("ID :%s\n",st[i].id);
- printf("SEMESTER :%d\n",st[i].sem);
- }
- }
- k=st[0].cource;
- for(i=0; i<5; i++)
- {
- if(k<st[i].cource)
- {
- k=st[i].cource;
- }
- }
- printf("\nMost Course TAKEN STUDENT:\n");
- for(i=0; i<5; i++)
- {
- if(k==st[i].cource)
- {
- printf("NAME :%s\n",st[i].name);
- printf("ID :%s\n",st[i].id);
- printf("Cource :%d\n",st[i].cource);
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment