MCPcopy Create free account
hub / github.com/Lakhankumawat/LearnCPP / Insert

Function Insert

Q-Queue/CircularQueueUsingArray.cpp:5–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3int n=50, front=-1, rear=-1;
4int queue[50];
5void Insert(){
6int item;
7cout<<"Enter the item to insert: "<<endl;
8 cin>>item;
9 if(front== (rear+1)% n) //Condition of Circular Queue Overflow
10 {cout<<"Circular Queue Overflow"<<endl;}
11 else if(front==-1 && rear==-1)
12 {front=rear=0;
13queue[rear]=item;
14 }
15 else{
16 rear=(rear+1)% n;
17 queue[rear]=item;
18 }
19}
20void Delete(){ if(front==-1 && rear==-1){cout<<"Circular Queue Underflow"<<endl;} //Condition of Circular Queue Underflow
21 else if(front==rear){
22 cout<<"Item deleted from Circular queue is : "<< queue[front]<<endl;

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected