answersLogoWhite

0

How do you code fifo in c plus plus?

Updated: 12/13/2022
User Avatar

Wiki User

12y ago

Best Answer

#include<iostream.h>

#include<conio.h>

#include<process.h>

#define SIZE 10

int queue[SIZE];

int front=-1,rear=-1;

void insert();

void del();

void display();

void main()

{

int ch;

do

{

clrscr();

cout<<"\nMAIN MENU."<<endl;

cout<<"\n1. Insert."<<endl;

cout<<"\n2. Delete."<<endl;

cout<<"\n3. Display."<<endl;

cout<<"\n4 Exit.\n"<<endl;

cout<<"\nEnter your choice.(1-4) : ";

cin>>ch;

switch(ch)

{

case 1 : insert();

break;

case 2 : del();

break;

case 3 : display();

break;

case 4 : exit(0);

default : cout<<"\nInvalid Choice.";

}

getch();

}

while(1);

}

void insert()

{

int val;

if(rear==SIZE-1)

{

cout<<"OVERFLOW."<<endl;

return;

}

cout<<"\nEnter the value : ";

cin>>val;

if(rear==front)

{

rear++;

front++;

queue[rear]=val;

}

else

{

rear++;

queue[rear]=val;

}

}

void del()

{

if(front==-1)

{

cout<<"\nQueue is empty.";

return;

}

if(front==rear)

front=rear=-1;

else

front++;

}

void display()

{

int front_vir=rear;

if(front==-1)

{

cout<<"\nQueue is empty.\n";

return;

}

while(front_vir<=rear)

{

cout<<queue[front_vir]<< " ";

front_vir++;

}

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you code fifo in c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is C plus plus preprocessor software?

Sometimes, it is. Some implementations compile C++ code into C code, and then compile the C code.


What is the mean c plus plus in machine code?

It is used to distinguish between the C or C++


How do you Open a text file as C plus plus source code?

All C++ source code is is a text file with the .cpp extension. So if you save your code as *****.cpp then it is automatically C++ source code.


What is the Visual C plus plus 2008 Express Serial Code?

The Express edition of C++ does not require a serial code. It is free.


C plus plus code for payroll processing?

yihuy


What is the code to include a library in c plus plus?

#include &lt;libraryname&gt;


What are the steps in c plus plus?

Code, compile, link, run.


What is the differentiate of turbo c from turbo c plus plus?

Turbo C compiles c source. turbo c++ compiles c++ source code.


How C plus plus is better than C?

C++ is a language code for computer and lapatops which is used in programming but C is a grade so they are different.


Where do you get c plus plus software?

A good open source IDE for C++ would be Code::Blocks or Notepad++.


Where can you get the mseb bill generation project in c plus plus?

No such code exists for MSEB Bill Generation in C++.


What is the code to perform friend function in C plus plus?

Something like this: