TheAlgorithms/C++
1.0.0
All the algorithms implemented in C++
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
z
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
z
Variables
Typedefs
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
p
q
r
s
t
u
v
w
x
y
Typedefs
Related Symbols
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
w
z
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
z
Variables
Typedefs
Macros
Examples
▼
TheAlgorithms/C++
►
The Algorithms - C++
►
Contributor Covenant Code of Conduct
►
Code style convention
►
CONTRIBUTION GUIDELINES
►
Backtracking
Prime factorization
Guidelines for reviewers and maintainers
Todo List
►
Topics
►
Namespaces
►
Classes
▼
Files
▼
File List
►
backtracking
►
bit_manipulation
►
ciphers
►
cpu_scheduling_algorithms
►
data_structures
►
divide_and_conquer
►
dynamic_programming
►
games
►
geometry
►
graph
►
graphics
►
greedy_algorithms
►
hashing
►
machine_learning
►
math
►
numerical_methods
▼
operations_on_datastructures
►
array_left_rotation.cpp
►
array_right_rotation.cpp
►
circular_linked_list.cpp
circular_queue_using_array.cpp
get_size_of_linked_list.cpp
►
inorder_successor_of_bst.cpp
►
intersection_of_two_arrays.cpp
reverse_a_linked_list_using_recusion.cpp
►
reverse_binary_tree.cpp
selectionsortlinkedlist.cpp
►
trie_multiple_search.cpp
►
union_of_two_arrays.cpp
►
others
►
physics
►
probability
►
range_queries
►
scripts
►
search
►
sorting
►
strings
►
File Members
►
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
circular_queue_using_array.cpp
1
#include <iostream>
2
using
std::cin;
3
using
std::cout;
4
5
int
queue
[10];
6
int
front = 0;
7
int
rear = 0;
8
int
count = 0;
9
10
void
Enque(
int
x) {
11
if
(count == 10) {
12
cout <<
"\nOverflow"
;
13
}
else
{
14
queue
[rear] = x;
15
rear = (rear + 1) % 10;
16
count++;
17
}
18
}
19
20
void
Deque() {
21
if
(front == rear) {
22
cout <<
"\nUnderflow"
;
23
}
24
25
else
{
26
cout <<
"\n"
<<
queue
[front] <<
" deleted"
;
27
front = (front + 1) % 10;
28
count--;
29
}
30
}
31
32
void
show() {
33
for
(
int
i = 0; i < count; i++) {
34
cout <<
queue
[(i + front) % 10] <<
"\t"
;
35
}
36
}
37
38
int
main
() {
39
int
ch, x;
40
do
{
41
cout <<
"\n1. Enque"
;
42
cout <<
"\n2. Deque"
;
43
cout <<
"\n3. Print"
;
44
cout <<
"\nEnter Your Choice : "
;
45
cin >> ch;
46
if
(ch == 1) {
47
cout <<
"\nInsert : "
;
48
cin >> x;
49
Enque(x);
50
}
else
if
(ch == 2) {
51
Deque();
52
}
else
if
(ch == 3) {
53
show();
54
}
55
}
while
(ch != 0);
56
57
return
0;
58
}
queue
Definition
queue.hpp:9
main
int main()
Main function.
Definition
generate_parentheses.cpp:110
operations_on_datastructures
circular_queue_using_array.cpp
Generated by
1.12.0