Your ultimate guide in programming...

  • Infix to Postfix Converstion

    * C++ implementation to convert infix expression to postfix*

  • DOUBLY QUEUE IMPLEMENTATION C++

    Double Queue Implemention Guide.

  • Data Structures in JavaScript

    As business logic moves from the back to the front, expertise in front-end engineering becomes even more important. As for front-end engineers, we rely on viable libraries to be effective.

  • Coding Problem To Solve Exercise 1

    here is Some Coding Problem For Beginners To Boost up their Confidence and to get grip on programming. This problem is for beginner levels for their brainstorming.

  • Coding Problem To Solve Exercise 2

    here is Some Coding Problem For Beginners To Boost up their Confidence and to get grip on programming. This problem is for beginner levels for their brainstorming.

  • Coding Problem To Solve Exercise 3

    * here is Some Coding Problem For Beginners To Boost up their Confidence and to get grip on programming. This problem is for beginner levels for their brainstorming.*

Showing posts with label Queue Using Link List. Show all posts
Showing posts with label Queue Using Link List. Show all posts

Queue Using Linked List c++


#include<iostream>
using namespace std;
struct Node{
int data;
Node *next;
};
class Queue_Linklist{
Node *front;
Node *rear;
public:
Queue_Linklist(){
rear = front = NULL;
}
void insert(int num){
Node *temp = new Node;
temp->data = num;
temp->next = NULL;
if(rear == NULL){
rear = temp;
front = temp;
}
else{
rear->next = temp;
rear = temp;
}
}
int remove(){
int copy = front->data;     
Node *del = front;
front = front->next;
if(front == NULL){
rear = NULL;
}
delete del;
return copy;
}
void Display()
{
Node *temp = front;
cout<<"DATA IN QUEUE IS: ";
while(temp != NULL){
cout<<temp->data<<" ";
temp = temp->next;
}
}
};
int main()
{
Queue_Linklist Q;
char choice;
do{
int input;
cout<<"1) TO INSERT NUMBER: \n";
cout<<"2) TO REMOVE NUMBER: \n";
cout<<"33) TO DISPLAY QUEUE: ";
cin>>input;
system("cls");
switch(input){
case 1:{
int num;
cout<<"ENTER NUMBER: ";
cin>>num;
Q.insert(num);
break;
}
case 2:{
cout<<"REMOVED NUMBER IS: "<<Q.remove()<<endl;
break;
}
case 3:{
Q.Display();
break;
}
default:{
cout<<"EROR 404: "<<endl;
break;
}
}
cout<<"\nDO YOU WANT TO CONT...(Y/N)...";
cin>>choice;
system("cls");
}while(choice == 'y');
return 0;
}

Share:

Newest Post

Coding Problem To Solve Exercise 3

                   Coding Problem To Solve Exercise 3 Objectives: Practice and understanding of basic c++ programs Control Structure(repetit...

Popular Posts

Recent Posts