Maintain Student record using link list

Problem Statement
Write a c program to store information about students using link list
you should store information about his name,age,height ,
(this is a test program if you understand how to do this program then you can store any number of information)

#include<stdio.h>
#include<stdlib.h>
typedef struct stud
{
  char name[20];
  int age;
  int height;
  struct stud *next;
}student,*point;
int main()
{
  int n,i;
  point a,temp;
  printf("enter the number of students\n");
  scanf("%d",&n);
  a=NULL;
  for(i=0;i<n;i++)
    {
      printf("student %d:\n",i+1);
      temp=(point)malloc(sizeof(student));
      temp->next=NULL;
      printf("enter name ");
      scanf("%s",temp->name);
      printf("enter age ");
      scanf("%d",&temp->age);
      printf("enter height ");
      scanf("%d",&temp->height);
      temp->next=a;
      a=temp;
    }


  printf("now i print the information about students \n");
  while(a!=NULL)
    {
      printf("student %d:\n",i+1);
      i--;
      printf("name: %s\n age: %d\n height: %d\n",a->name,a->age,a->height);
      a=a->next;
    }


  return 0;
}                                

5 comments:

  1. very helpful thank u

    ReplyDelete
  2. thanx a lot..!!! :)

    ReplyDelete
  3. how to display all information which i have entered

    ReplyDelete
    Replies
    1. while(a!=NULL)
      {
      printf("student %d:\n",i+1);
      i--;
      printf("name: %s\n age: %d\n height: %d\n",a->name,a->age,a->height);
      a=a->next;
      }
      this prints the information entered by you

      Delete