Miti059

az file

Sep 22nd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.17 KB | None | 0 0
  1. #include<stdio.h>
  2. struct student
  3. {
  4.  
  5.     char name[20];
  6.     char id[10];
  7.     int sem;
  8.     int cource;
  9. } st;
  10. int main()
  11. {
  12.      struct student st[5];
  13.     int i,j,k;
  14.     for(i=0; i<5; i++)
  15.     {
  16.         gets(st[i].name);
  17.         gets(st[i].id);
  18.         scanf("%d",&st[i].sem);
  19.         getchar();
  20.         scanf("%d",&st[i].cource);
  21.         getchar();
  22.  
  23.     }
  24.     j=st[0].sem;
  25.     for(i=0; i<5; i++)
  26.     {
  27.         if(j<st[i].sem)
  28.         {
  29.             j=st[i].sem;
  30.         }
  31.     }
  32.     printf("\nSenior:\n");
  33.     for(i=0; i<5; i++)
  34.     {
  35.         if(j==st[i].sem)
  36.         {
  37.             printf("NAME :%s\n",st[i].name);
  38.             printf("ID  :%s\n",st[i].id);
  39.             printf("SEMESTER :%d\n",st[i].sem);
  40.  
  41.         }
  42.  
  43.     }
  44.     k=st[0].cource;
  45.     for(i=0; i<5; i++)
  46.     {
  47.         if(k<st[i].cource)
  48.         {
  49.             k=st[i].cource;
  50.         }
  51.     }
  52.     printf("\nMost Course TAKEN STUDENT:\n");
  53.     for(i=0; i<5; i++)
  54.     {
  55.         if(k==st[i].cource)
  56.         {
  57.             printf("NAME :%s\n",st[i].name);
  58.             printf("ID  :%s\n",st[i].id);
  59.             printf("Cource :%d\n",st[i].cource);
  60.         }
  61.  
  62.     }
  63.  
  64.     return 0;
  65. }
Add Comment
Please, Sign In to add comment