Advertisement
RAJIBRAJU

structure

Sep 17th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include<stdio.h>
  2. typedef struct st
  3. {
  4. char name[25],id[25];
  5. int semi,credit;
  6.  
  7.  
  8. } data;
  9.  
  10.  
  11. int main ()
  12. {
  13.     data a[5];
  14.     int i,semester=0,course=0;
  15.     for(i=0;i<5;i++)
  16.     {
  17.         scanf(" %[^\n]",a[i].name);
  18.          scanf(" %[^\n]",a[i].id);
  19.           scanf("%d",&a[i].semi);
  20.            scanf("%d",&a[i].credit);
  21.     }
  22.     course=a[0].credit;
  23.  
  24.  for(i=0;i<5;i++)
  25.  {
  26.  
  27.      if(a[i].semi>semester) {
  28.         semester=a[i].semi;
  29.      }
  30.      if(course>a[i].credit)
  31.      {
  32.          course=a[i].credit;
  33.  
  34.      }
  35.  
  36.  }
  37.  
  38.  
  39.  for(i=0;i<5;i++) {
  40.  
  41.     if(a[i].semi==semester)
  42.     {
  43.         printf("most seniour %s\n%s\n%d\n%d\n",a[i].name,a[i].id,a[i].semi,a[i].credit);
  44.     }
  45.     if(course==a[i].credit)
  46.     {
  47.         printf("most seniour %s\n%s\n%d\n%d\n",a[i].name,a[i].id,a[i].semi,a[i].credit);
  48.     }
  49.  
  50.  }
  51.  
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement