Stack Linked
Stack Linked
h>
#include<stdlib.h>
struct Node
int data;
};
void display()
temp=Front;
else
while(temp!=NULL)
printf("%d->",temp->data);
temp=temp->link;
printf("NULL");
void Enqueue()
temp=Rear;
scanf("%d",&New->data);
New->link=NULL;
if(Rear==NULL)
Rear=New;
Front=New;
else
Rear->link=New;
Rear=New;
display(Front);
void Dequeue()
temp=Front;
if(temp==NULL)
printf("\nQueue is Empty....");
else
Front=Front->link;
free(temp);
display(Front);
}
int main()
int ch;
do
printf("\n*");
printf("\n*");
printf("\n1. Enqueue");
printf("\n2. Dequeue");
printf("\n3. Display");
printf("\n0. Exit");
scanf("%d",&ch);
switch(ch)
case 1:
Enqueue();
break;
case 2:
Dequeue();
break;
case 3:
display();
break;
case 0:
exit(0);
default:
printf("\nInvalid Option...");
break;
}while(ch!=0);