include<stdio.h>
include<conio.h>
include<stdlib.h>
struct node{ int data; struct node *next; };
void insert(struct node h) { struct node t,l; int d; t=(struct node)malloc(sizeof(struct node)); printf("enter the vlue"); scanf("%d",&d); if(h==NULL) { t->data=d; t->next=NULL; h=t; l=t; } else { l->next=t; t->data=d; t->next=NULL; } } void display(struct node h) { while(h!=NULL) { printf("%5d ",h->data); h=h->next; } } int main() { struct node h=NULL; char m; while(1) { clrscr(); printf("\n 1.insert"); printf("\n 2.display"); printf("\nenter 3 for exit"); printf("\nenter choice"); scanf("%c",&m); switch(m) { case '1':insert(h); break; case '2':display(h); break; case '3':return(0); }
getch(); } }