WAP To Creat single linklist and enter the first Node.

#include<stdio.h>
#include<conio.h>

//Def:->WAP To Creat single linklist and enter the first Node.
struct linklist
{
   int no;
   struct linklist *next;
};
typedef struct linklist node;
void main()
{
   void creat(node*);
   void display(node*);
   node *insfir(node*);
   node *head;
   clrscr();

   head=(node*)malloc(sizeof(node));
   creat(head);
   display(head);
   head=insfir(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("\nEnter Node is=>%d",list->no);
    list=list->next;
  }
}

node *insfir(node *list)
{
   node *new1;
   new1=(node*)malloc(sizeof(node));
   printf("\nEnter the first node=>");
   scanf("%d",&new1->no);
   new1->next=list;
   list=new1;
   return list;
}
WAP To Creat single linklist and enter the first Node. WAP To Creat single linklist and enter the first Node. Reviewed by Unknown on 5:35:00 PM Rating: 5

No comments:

Powered by Blogger.