Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Circular Queue Array in Data Structure used C Language.
WhatsApp
Sreenath Ks
Jan 08
2016
1.1
k
0
0
CIRCULAR QUEUE ARRAY IN DATA STRUCTURE.
#
include < stdio.h >
int
rear = 0;
int
front = 0;
int
max = 25;
int
cqueue[100];
main()
{
int
ch;
void
insert();
void
delete();
void
isempty();
void
isfull();
void
showcqueue();
do
{
int
data;
printf(
"\t*******CQUEUE ARRAY********"
);
printf(
"\t==========================\n"
);
printf(
"\t 1:insert\n"
);
printf(
"\t 2:delete\n"
);
printf(
"\t 3:isempty\n"
);
printf(
"\t 4:isfull\n"
);
printf(
"\t 5:show cqueue\n"
);
printf(
"\t 7:stop\n"
);
printf(
"\t===========================\n"
);
printf(
"enter your choice\n"
);
scanf(
"%d"
, & ch);
switch
(ch)
{
case
1:
// call insert function and BREAK after that
{
insert();
break
;
}
case
2:
// call delete function and BREAK after that
{
delete();
break
;
case
3:
// call isempty function and BREAK after that
{
isempty();
break
;
}
case
4:
// call isfull function and BREAK after that
{
isfull();
break
;
}
case
5:
// call show function and BREAK after that
{
showcqueue();
break
;
}
case
6:
{
printf(
"program ended\n"
);
break
;
}
default
:
{
printf(
"enter valid choice"
);
break
;
}
}
}
// end of do while
while
(ch != 6);
}
//-------------------------------------------------------------//
void
insert()
//function to insert
{
int
data;
if
(front == (rear + 1) % max)
{
printf(
"queue is full\n"
);
}
else
{
rear = (rear + 1) % max;
printf(
"enter the data\n"
);
scanf(
"%d"
, & cqueue[rear]);
printf(
"\t inserted data\n"
);
}
}
//-----------------------------------------------------------//
void
delete()
//function to delete
{
if
(rear == front)
{
printf(
"\nstack is empty"
);
}
else
{
front = (front + 1) % max;
printf(
"%d"
, cqueue[front]);
printf(
"\n delete data"
);
}
}
//----------------------------------------------------------//
void
isempty()
//function to isempty
{
if
(rear == front)
{
printf(
"queue is empty"
);
}
else
{
printf(
"queue is not empty"
);
}
}
//----------------------------------------------------------//
void
isfull()
//function to isfull
{
if
(rear == front)
{
printf(
"queue is full"
);
}
else
{
printf(
"queue is not full"
);
}
}
//-----------------------------------------------------------//
void
showcqueue()
//function to top of stack
{
int
i;
printf(
"\n circular queue"
);
for
(i = front + 1; i <= rear; ++i)
{
printf(
"%d"
, cqueue[i]);
}
}
//------------------------------------------------------------//
THANK YOU FOR USE IN MY BLOG.ANOTHER STUDY PLEASE SEARCH IN THIS BLOG.
DATA STRUCTURE
C
Circular Queue Array
Up Next
Circular Queue Array in Data Structure used C Language.