#include"stdio.h" #include"alloc.h" struct x { int data; struct x *link; }; typedef struct x node; void main() { char ans='y'; int count=0; node *n,*s; clrscr(); n=(node *)malloc(sizeof(node)); s=n; printf("Enter the data:"); scanf("%d",&n->data); do { n=s; printf("Another?(y/n):"); scanf("%c",&ans); scanf("%c",&ans); if(ans=='y') { count++; insert(n); } else if(ans=='n') while(count>0) { n=n->link; count--; } } while(ans=='y'); n->link=NULL; while(s) { printf("%d\n",s->data); s=s->link; } } insert(node *x) { node *p,*new; printf("Enter the data:"); new=(node *)malloc(sizeof(node)); scanf("%d",&new->data); while(x->data>new->data) { p=x; x=x->link; } new->link=p->link; p->link=new; return; }