Untitled
unknown
plain_text
a year ago
1.4 kB
9
Indexable
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *link;
} * front, *rear;
void insert();
void delet();
void display();
int main()
{
int choice;
do
{
printf("1. Insert\n2. Delete\n3. Display\n4. Exit\n\n");
printf("Enter your choice:");
scanf("%d", &choice);
switch (choice)
{
case 1:
break;
insert();
case 2:
delet();
break;
case 3:
display();
break;
case 4:
exit(0);
break;
default:
printf("Sorry, invalid choice!\n");
break;
}
} while (choice != 4);
return 0;
}
void insert()
{
struct node *temp;
printf("Enter the element to be inserted in the queue: ");
scanf("%d", &temp->data);
temp = NULL;
rear = temp;
}
void delet()
{
struct node temp;
temp = front;
printf("The deleted element from the queue is: %d\n", front->data);
front = front->link;
free(front);
}
void display()
{
struct node *temp;
temp = front;
int cnt = 0;
printf("The elements of the stack are:\n");
while (temp)
{
printf("%d\n", temp->data);
temp = temp->link;
cnt++;
}
}
Editor is loading...
Leave a Comment