Search This Blog

Translate

C structure program example to find topper student

c program using structure which accept name and marks of student and find the topper,c structure program  accept name and marks of student and find the topper with source code ,c structure example , accept structure element and print using c




#include<stdio.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 marks of 3 student\n ");
     for(i=0;i<3;i++)
    {
printf("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 marks of 5 student");
     for(i=0;i<3;i++)
    {
     printf("\n");
      printf("%s  marks ",s[i].name);
      //fflush(stdin);
      printf(":  %d",s[i].mark);

    }


  printf(" \n\n Topper is ");
    printf("%s marks ",s[n].name);
  printf(":  %d",s[n].mark);

getch();


}

C Program example List

Google+ Badge