AIM: Program To Insert Element in Array
AIM: Program To Insert Element in Array
AIM: Program To Insert Element in Array
1
Faculty Signature………. Roll No. ………………….
ALGORITHM:
Here LA is linear array with N elements and K is the positive integer such that K<=N. This algorithm inserts an
element ITEM at the Kth position in array.
1. Set J=:N.
2. Repeat steps 3 and 4 while J>=K.
3. Set LA[J+1]:=LA[J].
4. SET:=J-1.
5. Set LA[K]:=ITEM.
6. Set N:+N+1.
7. Exit.
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
void main()
{
int j,k,n,p,a[10];
clrscr();
printf(" Enter number of elements to be inserted: ");
scanf("%d",&n);
printf("\n Enter the elements of array: ");
for(j=0;j<n;j++)
{
scanf("%d",&a[j]);
}
printf("\n Enter the new element to be inserted: ");
scanf("%d",&k);
printf("\n Enter the index position of new element: ");
scanf("%d",&p);
for(j=n;j>p;j--)
{
a[j]=a[j-1];
}
a[p]=k;
n++;
printf("Enter altered array is : ");
for(j=0;j<n;j++)
{
printf("\n %d",a[j]);
}
getch();
}
OUTPUT
Date of Exp: …………... Exp. No. 2
Faculty Signature………. Roll No. ……………….…
ALGORITHM:
Hera a LA is linear array with N elements and k IS THE POSITIVE integer such that K<=N. This algorithm
deletes the Kth element from LA.
1. Set ITEM:=LA[K].
2. Repeat for J:=KtoN-1:
Set LA[J]:=LA[J+1]
3. Set N=N-1.
4. Exit.
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,p,a[10];
clrscr();
printf("\n Enter number of elements: ");
scanf("%d",&n);
printf("\n Enter the elements:\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n Enter position of the element to be deleted: ");
scanf("%d",&p);
p--;
for(i=p;i<n-1;i++)
{
a[i]=a[i+1];
}
printf("\n Altered array:\n");
for(i=0;i<n-1;i++)
{
printf("%d\n",a[i]);
}
getch();
}
OUTPUT
Date of Exp: …………... Exp. No. 3
Faculty Signature………. Roll No. …………….………
ALGORITHM:
PROGRAM
CODING
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,j,k,a[10];
clrscr();
printf("\nEnter the number of elements: ");
scanf("%d",&n);
printf("\n Enter the elements of array: \n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]==a[j])
{
for(k=j;k<n-1;k++)
{
a[k]=a[k+1];
}
--n;
--j;
}
}
}
getch();
}
OUTPUT
Date of Exp: …………... Exp. No. 4
Faculty Signature………. Roll No. ……………..……
ALGORITHM:
MATMUL(A,B,C,M,P,N)
Let A be an M*P matrix array and B be a P*N matrix array. This algorithm stores the product of A and B in an
M*N matrix array C.
1. Repeat steps 2 to 4 for I= 1 to M
2. Repeat Steps 3 and 4 for J =1 to N
3. Set C [I,J] = 0
4. Repeat for K = 1 to P :
1. C [I,J] = C [I,J] + A [I,K] * B [K,J]
5. Exit.
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
void main()
{int i,j,k,ch,r,c,x[5][5],y[5][5],z[5][5];
clrscr();
printf("\nEnter the number of rows : ");
scanf("%d",&r);
printf("Enter the number of columns : ");
scanf("%d",&c);
printf("\nEnter the first matrix \n ");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
scanf("%d",&x[i][j]);
}
printf("\nEnter second matrix \n") ;
for(i=0;i<r;i++)
{ for(j=0;j<c;j++)
{ scanf("%d",&y[i][j]);
}
}
printf("\tMENU");
printf("\n1.Addition");
printf("\n2.Subtraction");
printf("\n3.Multiplication");
printf("\n4.Transpose");
switch(ch)
{
case 1 : { printf("\nSum of the two matrix is :\n");
for(i=0;i<r;i++)
{ for(j=0;j<c;j++)
{
printf("%d\t",z[i][j]=x[i][j]+y[i][j]);
}
printf("\n");
}
} break;
OUTPUT
Date of Exp: …………... Exp. No. 5
Faculty Signature………. Roll No. ………….………
ALGORITHM:
1. The array A is of length NNZ and holds all the nonzero entries of M in left-to-right top-to-bottom ("row-
major") order.
2. The array IA is of length m + 1. It is defined by this recursive definition:
3. IA[0] = 0
4. IA[i] = IA[i − 1] + (number of nonzero elements on the (i-1)-th row in the original matrix)
5. Thus, the first m elements of IA store the index into A of the first nonzero element in each row of M, and
the last element IA[m] stores NNZ, the number of elements in A, which can be also thought of as the index
in A of first element of a phantom row just beyond the end of the matrix M. The values of the i-th row of
the original matrix is read from the elements A[IA[i]] to A[IA[i + 1] − 1] (inclusive on both ends), i.e. from
the start of one row to the last index just before the start of the next.
6. The third array, JA, contains the column index in M of each element of A and hence is of length NNZ as
well.
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
void display(int a[5][5],int r,int c);
void main()
{
int a[5][5]={0},r,c,i,j,ch;
clrscr();
getch();
OUTPUT
Date of Exp: …………... Exp. No. 6
Faculty Signature………. Roll No. ……………..…
ALGORITHM
PUSH(MAXSTK,TOP,STACK,ITEM)
This procedure pushes an item onto a stack.
1. If TOP=MAXSTK, print OVERFLOW and Return.
2. Set TOP=TOP+1.
3. Set STACK[TOP]=ITEM.
4. Return.
POP(STACK,TOP,ITEM)
This procedure deletes the top element of stack and assigns it to variable ITEM.
1. If TOP=0, print UNDERFLOW and Return.
2. Set ITEM=STACK[TOP].
3. Set TOP=TOP-1.
4. Return.
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
#define SIZE 10
int stack[SIZE];
int top=-1;
int overflow();
int underflow();
void push();
void pop();
void display();
void main()
{
int z;
char c='y';
clrscr();
while(c=='y'|| c=='Y')
{
printf("\n Press 1 for Push");
printf("\n Press 2 for Pop");
printf("\n Press 3 for Traverse");
printf("\n Enter your choice: ");
scanf("%d",&z);
switch(z)
{
case 1:
printf("\n Push Operation");
push();
break;
case 2:
printf("\n Pop operation");
pop();
break;
case 3:
printf("\n Traverse operation");
display();
break;
default:
printf("\n Wrong choice");
}
printf("\n Do you want to continue (Y/N): ");
fflush(stdin);
scanf("%c",&c);
}
getch();
}
int overflow()
{
if(top==SIZE-1)
{
printf("\n Stack overflow");
return 1;
}
else
return 0;
}
int underflow()
{
if(top==-1)
{
printf("\n Stack underflow");
return 1;
}
else
return 0;
}
void push()
{
int a;
if(!overflow())
{
printf("\n Enter the element to insert: ");
scanf("%d",&a);
top=top+1;
stack[top]=a;
}
}
void pop()
{
if(!underflow())
{
printf("\n Popped element is: %d",stack[top]);
top=+top-1;
}
}
void display()
{
int i;
if(!underflow())
{
printf("\n After traverse program elements are: ");
for(i=0;i<=top;i++)
{
printf("%d\t",stack[i]);
}
}
}
OUTPUT
Date of Exp: …………... Exp. No. 7
Faculty Signature………. Roll No. ………………
ALGORITHM:
POLISH(Q,P)
Suppose Q is an arithmetic expression written in infix notation. This algorithm finds the equivalent postfix
expression P.
1) Push “(“ onto stack and add “)” to the end of Q.
2) Scan Q from left to right and repeat step 3 to 6 for each element of Q until the STACK is empty.
3) If an operand is encountered, add it to P.
4) If a left parenthesis is encountered, push it into STACK.
5) If an operator (*) is encountered then:
a) Repeatedly pop from STACK and add it to P each operator on top of STACK which has the same
precedence than (*).
b) Add (*) to STACK.
6) If a right parenthesis is encountered then.
a) Repeatedly pop from STACK and add to P each operator on top of STACK until a left parenthesis is
encountered.
b) Remove the left parenthesis.
7) Exit.
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
char stack[50];
int top=-1;
void in_to_post(char infix[]);
void push (char);
char pop();
void main()
{
char infix[25];
clrscr();
printf("\n Enter infix expression: ");
gets(infix);
in_to_post(infix);
getch();
}
void push(char symb)
{
if(top>=49)
{
printf("\n Stack overflow!!!");
getch();
return;
}
else
{
top=top+1;
stack[top]=symb;
}
}
char pop()
{
char item;
if(top==-1)
{
printf("\n Stack empty!!!");
getch();
return(0);
}
else
{
item=stack[top];
top--;
}
return item;
}
OUTPUT
Date of Exp: …………... Exp. No. 8
Faculty Signature………. Roll No. ………………
ALGORITHM:
REVERSE POLISH(Q,P)
1) Suppose Q is an arithmetic expression written in infix notation. This algorithm finds the equivalent prefix
expression P.
2) Reverse the set of string.
3) Push “(“ onto stack and add “)” to the end of Q.
4) Scan Q from left to right and repeat step 3 to 6 for each element of Q until the STACK is empty.
5) If an operand is encountered, add it to P.
6) If a left parenthesis is encountered, push it into STACK.
7) If an operator (*) is encountered then:
a) Repeatedly pop from STACK and add it to P each operator on top of STACK which has the same
precedence than (*).
b) Add (*) to STACK.
8) If a right parenthesis is encountered then.
a) Repeatedly pop from STACK and add to P each operator on top of STACK until a left parenthesis is
encountered.
b) Remove the left parenthesis.
9) Reverse the string again.
10) Exit.
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#define max 100
char st[max];
int top=-1;
void push(char st[],char);
char pop(char st[]);
void infixpostfix(char source[],char target[]);
int getpriorty(char);
void reverse(char str[]);
char infix[100],postfix[100],temp[100];
int main()
{
clrscr();
printf("\n Enter any infix expression:");
gets(infix);
reverse(infix);
strcpy(postfix," ");
infixpostfix(temp,postfix);
reverse(postfix);
printf("\n Prefix string:");
puts(temp);
getch();
return 0;
}
temp[i]='\0';
}
while((top!=-1)&&(st[top]!='('))
{
target[j]=pop(st);
j++;
}
target[j]='\0';
}
OUTPUT
Date of Exp: …………... Exp. No. 9
Faculty Signature………. Roll No. ………………
ALGORITHM:
This algorithm is to find the value of an arithmetic expression P within postfix notation.
1. Add a right parenthesis “)“ at the end of P.
2. Add P from left to right and repeat step 3 and 4 for each element of P until the sentinel “)” is encountered.
3. If an operand is encountered, put it in stack.
4. If an operator is encountered, then,
a. Remove the top two elements of stack where A is the top element and B is next to top element.
b. Evaluate B(*)A.
c. Place the result of(b) back on stack.
5. Set VALUE equal to the top element of stack.
6. Exit.
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
#include<math.h>
void evaluate();
void push(float f);
float pop();
char q[20];
float stack[20];
int top=-1;
void main()
{
clrscr();
void push(float f)
{
top++;
stack[top]=f;
}
float pop()
{
return(stack[top--]);
}
OUTPUT
Date of Exp: …………... Exp. No. 10
Faculty Signature………. Roll No. ………………
ALGORITHM:
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
#include<string.h>
char stack[20];
int top=-1;
void push(char);
char pop();
void main()
{
char str[20],ch;
int l,i;
clrscr();
printf("\nEnter String: ");
gets(str);
l=strlen(str);
for(i=0;i<l;i++)
push(str[i]);
printf("\nReversed String: ");
for(i=0;i<l;i++)
{
ch=pop();
printf("%c",ch);
}
getch();
}
void push(char c)
{
top++;
stack[top]=c;
}
char pop()
{
char c;
c=stack[top];
top--;
return c;
}
OUTPUT
Date of Exp: …………... Exp. No. 11
Faculty Signature………. Roll No. ………………
ALGORITHM
QINSERT(QUEUE,N,FRONT,REAR,ITEM)
This procedure inserts an element(item) into a queue.
1. If FRONT=1 and REAR=N, or if FRONT=REAR+1 then, write OVERFLOW and return.
2. If FRONT=NULL, then,
a) Set FRONT=1, and REAR=1
b) Else if REAR=N, then,
c) Set REAR=1.
d) Else
e) Set REAR=REAR+1.
3. Set QUEUE [REAR]=ITEM.
4. Return.
QDELETE(QUEUE,N,FRONT,REAR,ITEM)
This procedure deletes an element from a queue and assigns it to variable ITEM.
1) If FRONT=NULL, then, write UNDERFLOW and Return.
2) Set ITEM=QUEUE [FRONT].
3) If FRONT=REAR, then:
a) Set FRONT=NULL and REAR=NULL.
b) Else if FRONT=N then
c) Set FRONT=1.
d) Else
e) Set FRONT=FRONT+1.
4) Return.
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
#define MAX 50
void insert_queue();
void delete_queue();
void display();
int queue[MAX],f=-1,r=-1;
void main()
{
int choice;
char ch='y';
clrscr();
while(ch=='y'|| ch=='Y')
{
printf("\n1. Insertion");
printf("\n2. Deletion");
printf("\n3. Display");
printf("\n \n Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1:insert_queue();
break;
case 2:delete_queue();
break;
case 3:display();
break;
default: printf("\n Wrong choice enetered!!!!");
}
printf("\n\nDo you want to continue? (Y/N): ");
fflush(stdin);
scanf("%c",&ch);
}
getch();
}
void insert_queue()
{
int ele;
printf("\nEnter element you want to insert : ");
scanf("%d",&ele);
if(r==MAX-1)
{ printf("\nQueue OVERFLOW");
}
else
{
if(f==-1)
{
f=0;
r=0;
}
else
{
r=r+1;
}
queue[r]=ele;
}
}
void display()
{
int i;
if(f==-1)
{
printf("\n Queue UNDERFLOW");
}
else
{
for(i=f;i<=r;i++)
printf("\nElement: %d",queue[i]);
}
}
void delete_queue()
{ int i;
if(f==-1)
{
printf("Queue UNDERFLOW");
}
else
{
printf("\n Deleted Element is :%d",queue[f]);
f=f+1;
}
}
OUTPUT
Date of Exp: …………... Exp. No. 12
Faculty Signature………. Roll No. …………………
AIM: Program to perform Insert, Delete & Display operations on Circular Queue
ALGORITHM:
1. If FRONT = -1 then
Write ("Circular Queue Underflow")
2. Return (CQ [FRONT])
3. If FRONT = REAR then
FRONT=REAR=-1
4. If FRONT = SIZE-1 then
FRONT=0
Else
FRONT=FRONT+1
5. Exit.
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define MAX 50
void enqueue();
void dequeue();
void display();
int cqueue[MAX],f=-1,r=-1;
void main()
{
int choice;
char ch='y';
clrscr();
while(ch=='y'|| ch=='Y')
{
printf("\n1. Insertion");
printf("\n2. Deletion");
printf("\n3. Display");
printf("\n Enter your choice :");
scanf("%d",&choice);
switch(choice)
{
case 1:enqueue();
break;
case 2:dequeue();
break;
case 3:display();
break;
default: printf("\nYou have entered wrong choice");
}
printf("\nDo you want to continue? (Y/N): ");
fflush(stdin);
scanf("%c",&ch);
}
getch();
}
void enqueue()
{
int ele;
if((f==0 && r==MAX-1)|| (f==r+1))
{
printf("\nQueue Overflow");
}
else
{
printf("\nEnter the element you want to insert : ");
scanf("%d",&ele);
if(f==-1)
{
f=0;
r=0;
}
else
{
if(r==MAX-1)
r=0;
else
r=r+1;
}
cqueue[r]=ele;
}
}
void dequeue()
{
if(f==-1)
{
printf("\nQueue Underflow ");
}
else
{
printf("Deleted element is :\t%d ",cqueue[f]);
if(f==r)
{
r=-1;
f=-1;
}
}
}
void display()
{
int i;
if(f==-1)
{
printf("\nQueue Underflow");
}
else
{
if(f<=r)
{
for(i=f;i<=r;i++)
printf("\nElement: %d",cqueue[i]);
}
else
{
for(i=f;f<MAX;i++)
printf("\nElement: %d",cqueue[i]);
for(i=0;i<r;i++)
printf("\nElement: %d",cqueue[i]);
}
}
}
OUTPUT
Date of Exp: …………... Exp. No. 13
Faculty Signature………. Roll No. …………..………
AIM: Program to perform Insertion (Beginning, Between, End), Deletion (Beginning, Between, End) &
Traverse operations on Link List
ALGORITHM
CODING
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
void insert();
void display();
void insert_middle();
void insert_end();
void delet();
void delet_middle();
void delet_end();
struct node
{
int info;
struct node *next;
}*start=NULL;
void main()
{
char ch='y';
int a;
clrscr();
while(ch=='y' || ch=='Y')
{
printf("\n Press 1 for insertion in start");
printf("\n Press 2 for insertion in middle");
printf("\n Press 3 for insertion in end");
printf("\n Press 4 for display");
printf("\n Press 5 for deletion in start");
printf("\n Press 6 for deletion in middle");
printf("\n Press 7 for deletion in end\n");
printf("\n ENTER YOUR CHOICE : ");
scanf("%d",&a);
switch(a)
{
case 1:
insert();
break;
case 2:
insert_middle();
break;
case 3:
insert_end();
break;
case 4:
display();
break;
case 5:
delet();
break;
case 6:
delet_middle();
break;
case 7:
delet_end();;
break;
default: printf("\nYou Have Entered Wrong Choice !!");
}
printf("\n\n DO YOU WANT TO CONTINUE ?? Y/N:-\t");
fflush(stdin);
scanf("%c",&ch);
}
getch();
}
void insert()
{
struct node *ptr;
int item;
printf("\n Enter the element to be inserted at start: ");
scanf("%d",&item);
ptr=(struct node*)malloc(sizeof(struct node));
ptr->info=item;
if(start==NULL)
{
start=ptr;
ptr->next=NULL;
}
else
{
ptr->next=start;
start=ptr;
}
}
void display()
{
struct node*temp;
if(start==NULL)
{
printf("\n LIST CONTAINS NO MODE");
}
else
{
temp=start;
while(temp!=NULL)
{
printf("\n\n ELEMENTS ARE : %d",temp->info);
temp=temp->next;
}
}
}
void insert_middle()
{
struct node*current,*prev=NULL,*temp;
int item;
printf("\nEnter the element to be inserted");
scanf("%d",&item);
temp=(struct node*)malloc(sizeof (struct node));
temp->info=item;
temp->next=NULL;
current=start;
while(current!=NULL)
{
if(current->info>=item)
break;
prev=current;
current=current->next;
}
if(prev==NULL)
start=temp;
else
prev->next=temp;
temp->next=current;
printf("Element inserted is : %d",temp->info);
void insert_end()
{
int item;
struct node *current,*temp;
printf("\n Enter the element to be inserted");
scanf("%d",&item);
temp=(struct node*)malloc(sizeof(struct node));
temp->info=item;
temp->next=NULL;
if(start==NULL)
start=temp;
else
{
current=start;
while(current->next!=NULL)
current=current->next;
}
current->next=temp;
void delet()
{
struct node *temp;
printf("\n\nDeleted element is : %d",start->info);
temp=start;
start=start->next;
free(temp);
}
void delet_middle()
{
struct node*current,*prev;
int item;
printf("Ente element to be deleted : ");
scanf("%d",&item);
if(start==NULL)
{
printf("\n Underflow");
}
current=start;
if(start->next==NULL)
{ start=NULL;
}
else
{
while(current->info!=item)
prev=current;
current=current->next;
}
prev->next=current->next;
printf("The deleted element is: %d",current->info);
free(current);
}
void delet_end()
{
struct node *current,*prev;
current=start;
if(start->next==NULL)
{
start=NULL;
}
else
{
while(current->next!=NULL)
{ prev=current;
current=current->next;
}
prev->next=NULL;
}
printf("Elemented deleted is : %d",current->info);
free(current);
}
OUTPUT
Date of Exp: …………... Exp. No. 14
Faculty Signature………. Roll No. ………………
AIM: Program to perform Pop, Push & Traverse operations on Dynamic Stack
ALGORITHM:
PUSH Algorithm
1. Declare a node from avail list with same size as of rest of the node in the list.
2. Set ptr-> info = item
3. Set ptr-> link = top
4. top = ptr
5. exit
POP Algorithm
Traverse Algorithm :
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
void push();
void display();
void pop();
struct node
{
int info;
struct node *next;
}*top=NULL;
void main()
{
char ch='y';
int a;
clrscr();
while(ch=='y' || ch=='Y')
{
printf("\n Press 1 for push operation on dynamic stack ");
printf("\n Press 2 for pop operation on dynamic stack");
printf("\n Press 3 for display");
void push()
{
struct node *ptr;
int item;
printf("\n Enter the element to be inserted at start: ");
scanf("%d",&item);
ptr=(struct node*)malloc(sizeof(struct node));
ptr->info=item;
if(top==NULL)
{
top=ptr;
ptr->next=NULL;
}
else
{
ptr->next=top;
top=ptr;
}
}
void display()
{
struct node*temp;
if(top==NULL)
{
printf("\n LIST CONTAINS NO MODE");
}
else
{
temp=top;
while(temp!=NULL)
{
printf("\n ELEMENTS ARE : %d",temp->info);
temp=temp->next;
}
}
}
void pop()
{
struct node *temp;
printf("\n Deleted element is : %d",top->info);
temp=top;
top=top->next;
free(temp);
}
OUTPUT
Date of Exp: …………... Exp. No. 15
Faculty Signature………. Roll No. …………..………
AIM: Program to perform Insert, Delete & Display operations on Dynamic Queue
ALGORITHM:
1. If FRONT = -1 then
Write “Queue is Underflow”
2. Return QUEUE [FRONT]
If FRONT = REAR then
FRONT = 0
REAR = 0
Else
FRONT = FRONT + 1
3. Exit
PROGRAM:
CODING
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
void enqueue();
void dequeue();
void display();
struct node
{
int info;
struct node*next;
}*rear=NULL;
void main()
{ char ch='y';
int a;
clrscr();
while(ch=='y'||ch=='Y')
{
printf("\n1. Insert elements into Dynamic Queue");
printf("\n2. Delete elements from Dynamic Queue");
printf("\n3. Traverse elements of Dynamic Queue");
printf("\nEnter your choice : ");
scanf("%d",&a);
switch(a)
{
case 1: enqueue();
break;
case 2: dequeue();
break;
case 3:display();
break;
default: printf("\nYou have entered a wrong choice");
}
printf("\nDo you want to continue ? Y/N ");
fflush(stdin);
scanf("%c",&ch);
}
getch();
}
void enqueue()
{
int item;
struct node *current,*temp;
printf("\n Enter the element: ");
scanf("%d",&item);
temp=(struct node*)malloc(sizeof(struct node));
temp->info=item;
temp->next=NULL;
if(rear==NULL)
rear=temp;
else
{
current=rear;
while(current->next!=NULL)
{
current=current->next;
}
current->next=temp;
}
}
void dequeue()
{
struct node *temp;
printf("\n Deleted element is : %d",rear->info);
temp=rear;
rear=rear->next;
free(temp);
}
void display()
{
struct node*temp;
if(rear==NULL)
{
printf("\nQueue contain no element");
}
else
{
temp=rear;
printf("\nElements in Queue are: ");
while(temp!=NULL)
{
printf("%d\t",temp->info);
temp=temp->next;
}
}
}
OUTPUT