Ds Programs Sybcs
Ds Programs Sybcs
Q. Create a random array of n integers. Accept a value x from user and use linear search algorithm to
check whether the number is present in the array or not and output the position if the number is
present.
#include<stdio.h>
int main()
int a[50],i,size,data;
scanf("%d",&size);
scanf("%d",&a[i]);
scanf("%d",&data);
for(i=0;i<size;i++)
if(a[i]==data)
break;
} }
if(i==size)
} }
OUTPUT :-
Q. Accept n values in array from user. Accept a value x from user and use sentinel linear search
algorithm to check whether the number is present in the array or not and output the position if the
number is present.
#include <stdio.h>
int main() {
int n, x, arr[100];
scanf("%d", &n);
scanf("%d", &arr[i]);
scanf("%d", &x);
arr[n] = x;
int i = 0;
while (arr[i] != x) {
i++;
if (i == n) {
} else {
} return 0;
}
OUTPUT :-
Q. Accept n sorted values in array from user. Accept a value x from user and use binary search
algorithm to check whether the number is present in sorted array or not and output the position if
the number is present.
#include<stdio.h>
int main()
int i,size,data,lb,ub,mid;
int a[50];
scanf("%d",&size);
for(i=0;i<size;i++)
scanf("%d",&a[i]);
scanf("%d",&data);
lb=0;
ub=size-1;
mid=(lb+ub)%2;
if(data==a[mid])
else if(data<a[mid])
ub=mid-1;
else
lb=mid+1;
if(lb>ub)
return -1;
OUTPUT :-
Q. Sort a random array of n integers (accept the value of n from user) in ascending order by using
bubble sort algorithm.
#include<stdio.h>
int main()
int a[50];
int i,j,n,temp;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
for(j=0;j<n-1;j++)
if(a[j]>a[j+1])
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
OUTPUT :-
Q. Sort a random array of n integers (create a random array of n integers) in ascending order by using
insertion sort algorithm.
#include<stdio.h>
int main()
int a[20],i,j,key,n;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=1;i<n;i++)
{ key=a[i];
j=i-1;
a[j+1]=a[j];
j=j-1;
a[j+1]=key;
} }
for(i=0;i<n;i++)
printf("%d\n",a[i]);
} }
OUTPUT :-
Q. Sort a random array of n integers (accept the value of n from user) in ascending order by using
selection sort algorithm.
#include<stdio.h>
int main()
int a[20],i,j,n,min,temp;
scanf("%d",&n);
printf("enter an elements of an array");
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
min=i;
for(j=i+1;j<n;j++)
if(a[j]<a[min])
min=j;
} }
if(min!=i)
temp=a[i];
a[i]=a[min];
a[min]=temp;
} }
for(i=0;i<n;i++)
printf("%d",a[i]);
return 0;
OUTPUT :-
Q. Sort a random array of n integers (accept the value of n from user) in ascending order by using
recursive counting sort algorithm.
#include <stdio.h>
int arr1[10];
int x = arr[0];
if (arr[i] > x)
x = arr[i];
int count_arr[10];
count_arr[i] = 0;
count_arr[arr[i]]++;
arr1[count_arr[arr[i]] - 1] = arr[i];
count_arr[arr[i]]--;
arr[i] = arr1[i];
} }
printf("\n");
int main() {
int arr[50],n,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
countingSort(arr, n);
display(arr, n);
OUTPUT :-
1 2 3 5.
Q. Sort a random array of n integers (accept the value of n from user) in ascending order by using
recursive merge sort algorithm.
#include<stdio.h>
int main()
int a[20],i,j,n,min,temp;
scanf("%d",&n);
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
min=i;
for(j=i+1;j<n;j++)
if(a[j]<a[min])
min=j;
if(min!=i)
temp=a[i];
a[i]=a[min];
a[min]=temp;
for(i=0;i<n;i++)
printf("%d",a[i]);
} return 0;
}
OUTPUT :-
10 14 19 26 27 31 33 35 42 44 0
0 10 14 19 26 27 31 33 35 42 44 .
Q. Sort a random array of n integers (create a random array of n integers) in ascending order by using
recursive quick sort algorithm.
#include <stdio.h>
int i = low - 1;
i++;
ar[i] = ar[j];
ar[j] = temp;
ar[i + 1] = ar[high];
ar[high] = temp;
return i + 1;
}
void quickSort(int arr[], int low, int high)
quickSort(arr, pi + 1, high);
int main(void)
int n;
scanf("%d", &n);
int arr[n];
scanf("%d", &arr[i]);
quickSort(arr, 0, n - 1);
}
OUTPUT :-
0: 2
1: 4
2: 1
3: 3
1234
Q. Implement a list library (singlylist.h) for a singly linked list with the operations like
append,insert,search, delete,display. Write menu driven program to call the operations.
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
};
newNode->data = data;
newNode->next = NULL;
if (head == NULL) {
head = newNode;
} else {
current = current->next;
current->next = newNode;
newNode->data = data;
newNode->next = NULL;
if (pos == 0) {
newNode->next = head;
head = newNode;
} else {
int i;
if (current == NULL) {
return;
current = current->next;
if (current == NULL) {
} else {
newNode->next = current->next;
current->next = newNode;
}
}}
int pos = 0;
if (current->data == data) {
return pos;
current = current->next;
pos++;
return -1;
if (current->data == data) {
if (prev == NULL) {
head = current->next;
} else {
prev->next = current->next;
free(current);
return;
prev = current;
current = current->next;
}
void deleteByPosition(int pos) {
if (pos == 0) {
if (head == NULL) {
printf("List is empty.\n");
} else {
head = head->next;
free(temp);
} else {
int i;
if (current == NULL) {
return;
prev = current;
current = current->next;
if (current == NULL) {
} else {
prev->next = current->next;
free(current);
} }
void display() {
current = current->next;
printf("NULL\n");
int main() {
while (1) {
printf("1. Append\n");
printf("2. Insert\n");
printf("3. Search\n");
printf("6. Display\n");
printf("7. Exit\n");
scanf("%d", &choice);
switch (choice) {
case 1:
scanf("%d", &data);
append(data);
break;
case 2:
scanf("%d", &data);
scanf("%d", &pos);
insert(data, pos);
break;
case 3:
scanf("%d", &data);
result = search(data);
if (result != -1) {
} else {
break;
case 4:
scanf("%d", &data);
deleteByValue(data);
break;
case 5:
scanf("%d", &pos);
deleteByPosition(pos);
break;
case 6:
display();
break;
case 7:
exit(0);
default:
return 0;
}
OUTPUT :-
1. Append
2. Insert
3. Search
4. Delete by Value
5. Delete by Position
6. Display
7. Exit
1. Append
2. Insert
3. Search
4. Delete by Value
5. Delete by Position
6. Display
7. Exit
1. Append
2. Insert
3. Search
4. Delete by Value
5. Delete by Position
6. Display
7. Exit
1. Append
2. Insert
3. Search
4. Delete by Value
5. Delete by Position
6. Display
7. Exit
1. Append
2. Insert
3. Search
4. Delete by Value
5. Delete by Position
6. Display
7. Exit
1. Append
2. Insert
3. Search
4. Delete by Value
5. Delete by Position
6. Display
7. Exit
1. Append
2. Insert
3. Search
4. Delete by Value
5. Delete by Position
6. Display
7. Exit
1. Append
2. Insert
3. Search
4. Delete by Value
5. Delete by Position
6. Display
7. Exit
1. Append
2. Insert
3. Search
4. Delete by Value
5. Delete by Position
6. Display
7. Exit
1. Append
2. Insert
3. Search
4. Delete by Value
5. Delete by Position
6. Display
7. Exit
Q. . Implement a list library (singlylist.h) for a singly linked list. Create a linked list, reverse it and
display reversed linked list.
#include <stdio.h>
#include <stdlib.h>
struct node {
}*head;
void displayList();
int main()
int n, choice;
scanf("%d", &n);
createList(n);
displayList();
scanf("%d", &choice);
if(choice == 1)
reverseList();
displayList();
return 0;
void createList(int n)
int data, i;
if(n <= 0)
return;
}
if(head == NULL)
else
scanf("%d", &data);
temp = head;
if(newNode == NULL)
break;
else
scanf("%d", &data);
temp = temp->next; }
}
printf("SINGLY LINKED LIST CREATED SUCCESSFULLY\n");
void reverseList()
if(head != NULL)
prevNode = head;
curNode = head->next;
head = head->next;
while(head != NULL)
head = head->next;
curNode->next = prevNode;
prevNode = curNode;
curNode = head;
void displayList()
{
struct node *temp;
if(head == NULL)
printf("List is empty.");
else
temp = head;
while(temp != NULL)
} }
OUTPUT:-
Data = 10
Data = 20
Data = 30
Data = 40
Data = 50
Press 1 to reverse the order of singly linked list
Data = 50
Data = 40
Data = 30
Data = 20
Data = 10
Q. Implement a list library (doublylist.h) for a doubly linked list. Write a menu driven program to call
operations like append, insert, delete specific node, delete at position and display.
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
};
newNode->data = data;
newNode->prev = NULL;
newNode->next = NULL;
return newNode;
}
struct DoublyLinkedList {
};
if (dll->head == NULL) {
dll->head = newNode;
} else {
current = current->next;
current->next = newNode;
newNode->prev = current;
if (position == 1) {
newNode->next = dll->head;
if (dll->head != NULL) {
dll->head->prev = newNode;
dll->head = newNode;
} else {
int count = 1;
current = current->next;
count++;
}
if (current != NULL) {
newNode->next = current->next;
newNode->prev = current;
if (current->next != NULL) {
current->next->prev = newNode;
current->next = newNode;
} else {
printf("Invalid position\n");
if (current->data == key) {
if (current->prev != NULL) {
current->prev->next = current->next;
if (current->next != NULL) {
current->next->prev = current->prev;
if (current == dll->head) {
dll->head = current->next;
free(current);
return;
current = current->next;
current = current->next;
printf("NULL\n");
int main() {
dll.head = NULL;
while (1) {
printf("1. Append\n");
printf("4. Display\n");
printf("5. Exit\n");
scanf("%d", &choice);
switch (choice) {
case 1:
scanf("%d", &data);
append(&dll, data);
break;
case 2:
scanf("%d", &position);
printf("Enter the data to insert: ");
scanf("%d", &data);
break;
case 3:
scanf("%d", &key);
deleteNode(&dll, key);
break;
case 4:
display(&dll);
break;
case 5:
exit(0);
default:
return 0;
OUTPUT :-
1. Append
2. Insert at position
4. Display
5. Exit
1. Append
2. Insert at position
4. Display
5. Exit
1. Append
2. Insert at position
4. Display
5. Exit
1. Append
2. Insert at position
4. Display
5. Exit
2. Insert at position
4. Display
5. Exit
1. Append
2. Insert at position
4. Display
5. Exit
Q. Implement a list library (doublylist.h) for a doubly linked list. Create a linked list and display
reversed linked list.
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
};
struct DoublyLinkedList {
};
struct Node* createNode(int data) {
if (newNode == NULL) {
exit(1);
newNode->data = data;
newNode->prev = NULL;
newNode->next = NULL;
return newNode;
if (dll == NULL) {
exit(1);
dll->head = NULL;
dll->tail = NULL;
return dll;
if (dll->head == NULL) {
dll->head = newNode;
dll->tail = newNode;
} else {
dll->tail->next = newNode;
newNode->prev = dll->tail;
dll->tail = newNode;
}
}
temp = current->prev;
current->prev = current->next;
current->next = temp;
current = current->prev;
if (temp != NULL) {
dll->head = temp->prev;
current = current->next;
printf("NULL\n");
int main() {
append(dll, 1);
append(dll, 2);
append(dll, 3);
append(dll, 4);
append(dll, 5);
printf("Original Doubly Linked List: ");
display(dll);
reverse(dll);
display(dll);
current = current->next;
free(temp);
free(dll);
return 0;
OUTPUT :-
Original Doubly Linked List: 1 <-> 2 <-> 3 <-> 4 <-> 5 <-> NULL
Reversed Doubly Linked List: 5 <-> 4 <-> 3 <-> 2 <-> 1 <-> NULL
Q. Write a program that merges two ordered linked lists into third new list. When two lists are
merged the data in the resulting list are also ordered. The two original lists should be left unchanged.
That is merged list should be new one. Use linked implementation.
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
if (newNode == NULL) {
exit(1);
newNode->data = data;
newNode->next = NULL;
return newNode;
if (mergedList == NULL) {
mergedList = createNode(list1->data);
current = mergedList;
} else {
current->next = createNode(list1->data);
current = current->next;
list1 = list1->next;
} else {
if (mergedList == NULL) {
mergedList = createNode(list2->data);
current = mergedList;
} else {
current->next = createNode(list2->data);
current = current->next;
list2 = list2->next;
if (mergedList == NULL) {
mergedList = createNode(list1->data);
current = mergedList;
} else {
current->next = createNode(list1->data);
current = current->next;
list1 = list1->next;
if (mergedList == NULL) {
mergedList = createNode(list2->data);
current = mergedList;
} else {
current->next = createNode(list2->data);
current = current->next;
list2 = list2->next;
return mergedList;
list = list->next;
}
printf("NULL\n");
int main() {
list1->next = createNode(3);
list1->next->next = createNode(5);
list2->next = createNode(4);
list2->next->next = createNode(6);
printf("List 1: ");
printList(list1);
printf("List 2: ");
printList(list2);
printList(mergedList);
return 0;
OUTPUT :-
Q. Write a program that adds two single variable polynomials. Each polynomial should be
represented as a list with linked list implementation.
#include <stdio.h>
#include <stdlib.h>
struct Term {
int coefficient;
int exponent;
};
if (newTerm == NULL) {
exit(1);
newTerm->coefficient = coeff;
newTerm->exponent = exp;
newTerm->next = NULL;
return newTerm;
if (*polynomial == NULL) {
*polynomial = newTerm;
} else {
current = current->next;
current->next = newTerm;
}
}
if (exp1 == exp2) {
if (sum != 0) {
poly1 = poly1->next;
poly2 = poly2->next;
poly1 = poly1->next;
} else {
poly2 = poly2->next;
return result;
if (polynomial != NULL) {
printf(" + ");
printf("\n");
int main() {
insertTerm(&poly1, 3, 3);
insertTerm(&poly1, 2, 2);
insertTerm(&poly1, 1, 1);
insertTerm(&poly2, 2, 2);
insertTerm(&poly2, 5, 5);
insertTerm(&poly2, 4, 4);
printf("Polynomial 1: ");
printPolynomial(poly1);
printf("Polynomial 2: ");
printPolynomial(poly2);
printf("Result: ");
printPolynomial(result);
while (poly1 != NULL) {
poly1 = poly1->next;
free(temp);
poly2 = poly2->next;
free(temp);
result = result->next;
free(temp);
return 0;
OUTPUT :-
the stack and implementing the operations like init(S), S=push(S) and S=pop(S). Write
a driver program that includes stack library and calls different stack operations.
#include <stdio.h>
#define MAXSIZE 10
typedef struct
int data[MAXSIZE];
int top;
} STACK;
ps->top = -1;
ps->data[++ps->top] = num;
return (ps->data[ps->top--]);
return (ps->data[ps->top]);
}
int isempty(STACK *ps)
#include <stdio.h>
#include "stack.h"
void main()
int n, choice;
STACK s;
initstack(&s);
do
scanf("%d", &choice);
switch (choice)
case 1: /* PUSH */
if (isfull(&s))
else
push(&s, n);
break;
case 2: /*POP*/
if (isempty(&s))
printf("\nStack underflow");
else
break;
case 3: /*peek*/
if (isempty(&s))
printf("\nStack underflow");
else
OUTPUT :-
1:PUSH
2:POP
3:PEEK
1:PUSH
2:POP
3:PEEK
1:PUSH
2:POP
3:PEEK
1:PUSH
2:POP
3:PEEK
1:PUSH
2:POP
3:PEEK
1:PUSH
2:POP
3:PEEK
Circular Queue
linked list) implementation of the queue and implementing init(Q), AddQueue(Q) and
DeleteQueue(Q) operations. Write a menu driven program that includes queue library and
calls different queue operations.
#include <stdio.h>
#include <malloc.h>
int info;
} NODE;
void initq()
rear = NULL;
int isempty()
NODE *newnode;
newnode->info = num;
if (rear == NULL)
rear = newnode;
rear->next = rear;
else
{
rear->next = rear->next ;
rear->next = newnode;
rear = newnode;
int removeq()
free(rear);
else
rear->next= front->next;
free(front);
return (num);
int peek()
return rear->next->info;
#include<stdio.h>
#include "circularqueue.h"
void main()
do
printf("\n1.ADD\n2.REMOVE\n3.PEEK\n4.EXIT");
scanf("%d", &choice);
switch (choice)
case 1:
scanf("%d", &num);
addq(num);
break;
case 2:
if (isempty())
printf("\nQueue underflow");
else
break;
case 3:
peek();
break;
OUTPUT :-
1.ADD
2.REMOVE
3.PEEK
4.EXIT
1.ADD
2.REMOVE
3.PEEK
4.EXIT
1.ADD
2.REMOVE
3.PEEK
4.EXIT
1.ADD
2.REMOVE
3.PEEK
4.EXIT
Linear Queue
#include<stdio.h>
#define MAXSIZE 20
typedef struct
int data[MAXSIZE];
int front,rear;
}QUEUE;
pq->front=pq->rear=-1;
pq->rear++;
pq->data[pq->rear]=num;
int num;
pq->front++;
num=pq->data[pq->front];
return num;
return(pq->front==pq->rear);
}
return(pq->rear==MAXSIZE-1);
int i;
if(pq->front==pq->rear)
printf("\nQueue is Empty");
else
for(i=pq->front+1;i<=pq->rear;i++)
printf("\n%d",pq->data[i]);
printf("\n");
#include<stdio.h>
#include "Linearqueue.h"
void main()
int n,choice;
QUEUE q;
initqueue(&q);
do
printf("\n1:ADD\n2:REMOVE\n3:DISPLAY\n4:EXIT");
scanf("%d",&choice);
switch(choice)
case 1:if(isfull(&q))
printf("\nQueue is Overflow");
else
scanf("%d",&n);
add(&q,n);
display(&q);
break;
case 2:if(isempty(&q))
printf("\nQueue is Underflow");
else
break;
case 3:display(&q);
break;
while(choice!=4);
OUTPUT :-
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
2
5
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
implementation of the queue and implement init, enqueue, dequeue, isempty, peek operations.
#include<malloc.h>
int info;
}NODE;
NODE *front,*rear;
void initq()
front=rear=NULL;
int isempty()
return(front==NULL);
NODE *newnode;
newnode=(NODE*)malloc(sizeof(NODE));
newnode->info=num;
newnode->next=NULL;
if(front==NULL)
rear=front=newnode;
else
rear->next=newnode;
rear=newnode;
}
int removeq()
int num;
NODE *temp=front;
num=front->info;
front=front->next;
free(temp);
if(front==NULL)
rear=NULL;
return(num);
void display()
NODE *temp=front;
if(front==NULL)
printf("\nQueue is empty");
else
for(temp=front;temp!=NULL;temp=temp->next)
printf("\t%d",temp->info);
printf("\n");
#include<stdio.h>
#include "dyqueue.h"
void main()
{
int choice,num;
initq();
do
printf("\n1.ADD\n2.REMOVE\n3.DISPLAY\n4.EXIT");
scanf("%d",&choice);
switch(choice)
scanf("%d",&num);
addq(num);
break;
case 2:if(isempty())
printf("\nQueue underflow");
else
break;
case 3:display();
break;
while(choice!=4);
OUTPUT :-
1.ADD
2.REMOVE
3.DISPLAY
4.EXIT
1.ADD
2.REMOVE
3.DISPLAY
4.EXIT
1.ADD
2.REMOVE
3.DISPLAY
4.EXIT
1 2
1.ADD
2.REMOVE
3.DISPLAY
4.EXIT
Priority Queue
#include <stdio.h>
typedef struct
int data[MAXSIZE];
} QUEUE;
int i;
if(num>pq->data[i])
else
break;
pq->data[i+1]=num;
pq->rear++;
int num;
pq->front++;
num = pq->data[pq->front];
return (num);
int i;
if (pq->front == pq->rear)
printf("\nQueue is Empty");
else
printf("\n%d", pq->data[i]);
printf("\n");
#include<stdio.h>
#include "priorityQ.h"
void main()
{
int n,choice;
QUEUE q;
initqueue(&q);
do
printf("\n1:ADD\n2:REMOVE\n3:DISPLAY\n4:EXIT");
scanf("%d",&choice);
switch(choice)
case 1:if(isfull(&q))
printf("\nQueue is Overflow");
else
scanf("%d",&n);
addq(&q,n);
display(&q);
break;
case 2:if(isempty(&q))
printf("\nQueue is Underflow");
else
break;
case 3:display(&q);
break;
}
while(choice!=4);
OUTPUT :-
---Priority queue---
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
22
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
25
22
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
33
25
22
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
25
22
1:ADD
2:REMOVE
3:DISPLAY
4:EXIT
with the operations create, display. Write a menu driven program to call
these operations.
#include <stdio.h>
#include <stdlib.h>
int info;
} NODE;
int n, i;
scanf("%d", &n);
last = head;
newnode->next = NULL;
scanf("%d", &newnode->info);
last->next = newnode;
last = newnode;
NODE *temp;
printf("%d\t", temp->info);
#include <stdio.h>
#include <stdlib.h>
#include "singlylist.h"
void main()
NODE *head;
int choice;
head->next = NULL;
do
printf("\n1:CREATE:");
printf("\n2:DISPLAY:");
printf("\n3:EXIT:");
scanf("%d", &choice);
switch (choice)
case 1:
createlist(head);
break;
case 2:
display(head);
break;
OUTPUT :-
1:CREATE:
2:DISPLAY:
3:EXIT:
1:CREATE:
2:DISPLAY:
3:EXIT:
1 2
1:CREATE:
2:DISPLAY:
3:EXIT:
Enter your choice:
a) Implement a list library (doublylist.h) for a doubly linked list with the above four
operations. Write a menu driven driver program to call the operationsappend, insert, delete
#include<stdio.h>
#include<stdlib.h>
struct node
char data;
}*start;
void create()
printf("\nEnter a character:");
scanf(" %c",&temp->data);
temp->next=NULL;
temp->prev=NULL;
if(start==NULL)
start=temp;
else
{
q=start;
while(q->next!=NULL)
q=q->next;
q->next=temp;
temp->prev=q;
void display()
if(start==NULL)
return;
temp=start;
while(temp!=NULL)
printf("%d<-%c->%d->|",temp->prev,temp->data,temp->next);
temp=temp->next;
void delete()
int pos,t;
printf("\nEnter the position:");
scanf("%d",&pos);
t=1;
temp=start;
if(start==NULL)
return;
if(start->next==NULL)
free(start);
start=NULL;
return;
if(pos==1)
start=start->next;
start->prev=NULL;
free(temp);
return;
while(t< pos)
temp=temp->next;
t++;
temp->prev->next=temp->next;
if(temp->next!=NULL)
{
temp->next->prev=temp->prev;
free(temp);
#include<stdio.h>
#include "doublylist.h"
void main()
int c;
start=NULL;
while(1)
printf("\n1.Create\n");
printf("2.Delete\n");
printf("3.Display\n");
printf("4.Exit\n");
scanf("%d",&c);
switch(c)
case 4:exit(0);
}
OUTPUT :-
1.Create
2.Delete
3.Display
4.Exit
Enter a character:h
1.Create
2.Delete
3.Display
4.Exit
Enter a character:w
1.Create
2.Delete
3.Display
4.Exit
2.Delete
3.Display
4.Exit
0<-w->0->|
1.Create
2.Delete
3.Display
4.Exit