Thursday, September 25, 2014

WAP to read name, roll no, address and phone number of each student in you class using structure. Store the information in file so that you can recover the information later. While recovering the information from the file sort the information alphabetically according to the name.

#include
#include
 struct rec
            {
          int roll;
          char name[50];
          char add[20];
          long ph;
   }student[15];

void main()
{
   struct rec;
   int n,i,j;
   clrscr();
   printf("\n enter the no. of students: ");
   scanf("%d",&n);
   for(i=0; i
   {
      printf("\n enter roll no of student: ");
      scanf("%d",&student[i].roll);
      printf("\n enter name of student: ");
      scanf("%s",&student[i].name);
      printf("\n enter address of student in C: ");
      scanf("%s",&student[i].add);
      printf("\n enter phone of student in C: ");
      scanf("%ld",&student[i].ph);
   }
   for(i=0;i
   {

   printf("\n the records in ascending order are as follows: ");
   printf("\n roll \t\tname\t\taddress\t\tphone no");
   for(i=0; i
   {

      printf("\n  %d\t\t%s",student[i].roll,student[i].name);
      printf("\t\t  %s",student[i].add);
      printf("\t\t%ld",student[i].ph);
   }
   getch();

}

No comments:

Post a Comment