#include #include struct node { int data; struct node *link; }*x,*first; void opt(); void reading(); void check(int *); void display(); void main() { int option=0; first=x; clrscr(); while(1) { opt(); scanf("%d",&option); switch(option) { case 1: reading(); break; case 2: display(); break; case 3: exit(0); default: printf("\nINVALID OPTION\n"); } } } void opt() { printf("\nEnter your Choice\n\n"); printf("1.Read data and stuff it\n"); printf("2.Display Stuffed Data\n"); printf("3.EXIT\n\n"); } void reading() { int a,count=0; printf("\n please enter bit stram one by one .. press neter after every entry .. enter anything other than 0 or 1 to stopr entering \n"); while((scanf("%d",&a))) { if(a==1) { count++; x->data=a; // y=x; x->link=(struct node *)malloc(sizeof(struct node)); x=x->link; check(&count); } else if(a==0) { count=0; x->data=a; x->link=(struct node *)malloc(sizeof(struct node)); x=x->link; } else { x->data=a; x->link=NULL; printf("\n\nentering any other data stops entering ... now please press enter \n\n"); return; } } } void check(int *ct) { if(*ct==5) { x->data=0; x->link=(struct node *)malloc(sizeof(struct node)); x=x->link; ct=0; } } void display() { x=first; printf("\nStuffed Data is \n\n"); while(x->link!=NULL) { printf("%d",x->data); x=x->link; } }