0% found this document useful (0 votes)
8 views2 pages

Experiment No3print

The document outlines a program for implementing a Circular Queue using an array in C. It includes source code for various operations such as insertion, deletion, and display, along with handling underflow and overflow conditions. The program prompts the user for input and provides a menu for choosing operations until the user decides to exit.

Uploaded by

ansariaddu006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Experiment No3print

The document outlines a program for implementing a Circular Queue using an array in C. It includes source code for various operations such as insertion, deletion, and display, along with handling underflow and overflow conditions. The program prompts the user for input and provides a menu for choosing operations until the user decides to exit.

Uploaded by

ansariaddu006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Experiment No.

3
num=a[f];
Aim: Write a program to implement
Circular Queue using array. if(f==r)
{
Source Code:- f=r=-1;
}
#include<stdio.h>
void main() else if(f==max-1)
{ {
int f=-1,r=-1,max,num,i,a[100],ch; f=0;
printf("Enter The Length Of The }
Queue\n");
scanf("%d",&max); else
do {
{ f++;
printf("Choose The Operation \ }
n1.Insert \n2.Delete \n3.Display \n4.Exit\n");
scanf("%d",&ch); break;
switch(ch)
{ case 3:if(f==-1&&r==-1)
case 1:if((f==0&&r==max-1)|| {printf("Underflow\n");}
(f==r+1)) else
{printf("Overflow\n");} {
else if(f==-1&&r==-1) if(f<r){
{ for(i=f;i<=r;i++)
f=r=0;
printf("Enter the printf("%d\t",a[i]);
number to be entered\n"); }
scanf("%d",&num); else{
a[r]=num; for(i=f;i<=max-1;i++)
} printf("%d\t",a[i]);
for(i=0;i<=r;i++)
else if(r==max-1&&f!=0)
{ printf("%d",a[i]);
r=0; }
printf("Enter the }
number to be entered\n"); break;
scanf("%d",&num);
a[r]=num; case 4:return;
} }
}while(ch!=4);
else }
{
r++; OUTPUT:-
printf("Enter the
Enter The Length Of The Queue
number to be entered\n");
3
scanf("%d",&num);
Choose The Operation
a[r]=num;
1.Insert
}
2.Delete
3.Display
break;
4.Exit
1
case 2:if(f==-1)
Enter the number to be entered
{printf("Underflow\n");}
11 1.Insert
Choose The Operation 2.Delete
1.Insert 3.Display
2.Delete 4.Exit
3.Display 3
4.Exit Underflow
1 Choose The Operation
Enter the number to be entered 1.Insert
22 2.Delete
Choose The Operation 3.Display
1.Insert 4.Exit
2.Delete 4
3.Display
4.Exit
1
Enter the number to be entered
33
Choose The Operation
1.Insert
2.Delete
3.Display
4.Exit
1
Overflow
Choose The Operation
1.Insert
2.Delete
3.Display
4.Exit
3
11 22 33 Choose The Operation
1.Insert
2.Delete
3.Display
4.Exit
2
Choose The Operation
1.Insert
2.Delete
3.Display
4.Exit
3
22 33 Choose The Operation
1.Insert
2.Delete
3.Display
4.Exit
2
Choose The Operation
1.Insert
2.Delete
3.Display
4.Exit
2
Choose The Operation

You might also like