Create a Single Linklist Program

#include<stdio.h>
#include<conio.h>
struct linklist
{
    int no;
    struct linklist *next;
};
typedef struct linklist node;
void main()
{
   void creat(node*);
   void display(node*);
   node *head;
   clrscr();

   head=(node*)malloc(sizeof(node));
   creat(head);
   display(head);
   getch();
}
void creat(node *list)
{
   printf("\nEnter number -1 for end=>");
   scanf("%d",&list->no);
   if(list->no==-1)
   list->next=NULL;
   else
   {
     list->next=(node*)malloc(sizeof(node));
     creat(list->next);
   }
}
void display(node *list)
{
   while(list->next!=NULL)
   {
     printf("\nEnterred Node=>%d",list->no);
     list=list->next;
   }
}
Create a Single Linklist Program Create a Single Linklist Program Reviewed by Unknown on 5:40:00 PM Rating: 5

No comments:

Powered by Blogger.