Wednesday, April 25, 2018

Armstrong number

An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.

Code:


Output

Sunday, April 1, 2018

Verification of ‘L’ shaped arrangement of coins on game board (Id-1052)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1052

Consider an nxn board game with four types of coins red, green, blue and yellow. Given the state of the board with coins in all cells, develop an algorithm and write a C program to check if the same coins are placed in  the shape of ‘L’  on the board. The number of cells in the vertical and horizontal line of ‘L’ shape, is same. Red coins are represented by ‘r’, blue coins are represented by ‘b’, green coins are represented by ‘g’ and yellow coins are represented by ‘y’.

For example, given the configuration of a 4 X 4 board with coins as shown below, the program must print ‘Yes’ since the coin ‘r’ is placed in the positions (3,2), (4,2),(4,3),(4,4) form an ‘L’ shape.

b r y r

r r y b

y r b b

b r r r


Input Format

Number of rows

Number of columns

Elements in the matrix(board), given row by row

Output Format

Print Yes or No


Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 

Example: <pre> Your Code </pre>

Code: C++



NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

Black Coin in Board game (Id-1411)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1411

Colored coin game is a 8X8 board game which has many colored coins. Each coin has a weight and power. Power of a coin is defined by the moves that it can make. In a move,  a black coin can move one step vertically upwards.  A red coin can move one step either horizontally, vertically or diagonally. Given the current position of a black coin and list of movements made by it, print all possible next positions of the coin. If the total number of moves made by a black coin is greater than 6, then that coin should be treated as a red coin and the subsequent moves will be as that of the red coin. At any point of time, the coin cannot move outside the board. The rows and columns of the board are numbered as 1 to 8. Print the horizontal movement of coin in an increasing order of columns and print the vertical movement of coin in increasing order of rows. To print, the diagonal movement of the coin refer the sample board config given below. If the current position of your coin is 4,4 then print P1, P2 … P8 in order..

.

Input Format

Weight of black coin

Current row position of coin

Current column position of coin

Number of moves made by black coin

Output Format

Weight of black coin

List of possible next positions

One position in a line with row and column separated by a comma


Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 


Example: <pre> Your Code </pre>


Code: C++



NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

Special Pay Increase Problem (Id-1530)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1530

Employees in a company are up for a special pay increase. Given a file, with each line consisting of an employee’s last name, first name, current salary, and percent pay increase, write a C++ program to compute the revised pay of each employee.

Miller Andrew     65875.87  5
Green Sheila     75892.56 6
Sethi Amit        74900.50 6.1.

For example, the pay increase for Andrew is 5%.

Input Format

Name of the input file
The input file contains
last name, first name, salary and percentage of increase for employee1
last name, first name, salary and percentage of increase for employee2

last name, first name, salary and percentage of increase for employeen

Output Format

last name, first name, updadated salary of employee1 separated by a tab
last name, first name, updadated salary of employee2 separated by a tab
last name, first name, updadated salary of employee3 separated by a tab



Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 

Example: <pre> Your Code </pre>

Code: C++




NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

List of even Points (Id-2742)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 2742

Design a class point with datamembers: name of the point(string), value of the x-coordinate and the value of  y-coordinate. Here, value of the x-coordinate and the value of the y-coordinate should be an even integer. Provide functions to get the details of a point, print the details of a point and a function to compute the  squared distance between the point and a given point(passed to the function as an argument). Design a class mobileSpace, with a list of points(both the coordinates must be even integers) that represent the position of the mobile towers and a point that  represents the  position of mobile phone. With the position of the mobile towers and mobile phone given as input,   provide member functions to get the details and determine the tower  with which the mobile phone can be connected based on the `longest squared distance between the phone and the tower’ Use STL for implementation.


Input Format

Number of towers, ‘n’

Name of tower1

X-coordinate  of tower1

Y-coordinate of tower1



Name of tower-n

X-coordinate of tower-n

Y-coordinate  of tower-n

Name of mobile

X-coordinate  of mobile phone

Y-coordinate  of mobile phone


Output Format

Name of the tower to which the phone has to be connected


Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 

Example: <pre> Your Code </pre>


Code: C++



NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

College Application (Id-1410)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1410

A student may apply for an arts college or an engineering college after his school. Admission to arts college or engineering college, is based on the marks obtained in the six subjects : English, Second language, Maths, Physics, Chemistry and Computer Science.  Both the applications have the following details : application number, name, age, marks in all six subjects and cut-off for the eligibility. For Arts college, cut-off is the   average of  marks in all the subjects and whereas for engineering colleges cut-off is the average of marks in maths, physics, chemistry plus the marks scored in the entrance exam.  Given all the required details, Design an OOP model to compute the cut-off marks and implement it using C++.

Note: Syntax to print ‘x’ decimal places of variable ‘a’

include <iomanip>

use

cout<<fixed<<setprecision(x)<<a;


Input Format

Type of application (0 for arts student and 1 for engineering student)

Application Number

Name of student

Age

Marks scored in English

Marks scored in Second Language

Marks scored in Maths

Marks scored in Physics

Marks scored in Chemistry

Marks scored in Computer Science

Marks scored in entrance exam (only for engineering student)


Output Format

Name of student

Cut-off marks


Please Comment Working if the code worked to you
If you have other working codes please comment the codes enclosing with <pre> and </pre> 
Example: <pre> Your Code </pre>

Code: C++



NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

3-D points- multiply and increment (Id-2782)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 2782

Given a point in three-dimensional space with x-coordinate, y-coordinate, z-coordinates,  Provide a function increment with one, two and three parameters to transform  the values of all the three coordinates. When the function with one parameter is called increment all the three , by same value .  When the function with two arguments is called multiply each coordinates by the sum  of the two parameters. when the function with three arguments is called, increment x-coordinate  by the value of first parameter, y-coordinate by the value of the second parameter and z-coordinate  by the value of the third parameter.

Input Format

Enter the coordinates of the point

X-coordinate

Y-coordinate

Z-coordinate

Enter the increment value for function with one parameter

Enter the values for the function with two parameters

Enter the  increment values for function with three parameters

Output Format

Display the coordinates of the point after calling function with one parameter

Display the coordinates of the point after calling function with two parameters

Display the coordinates of the point after calling function with three parameters


Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 

Example: <pre> Your Code </pre>

Code: C++

#include< iostream >
using namespace std;
class dim
{
    int a,b,c;
    public :
    void get()
    {
        cin>>a>>b>>c;
    }
    void increment(int val)
    {
        a+=val;
        b+=val;
        c+=val;
    }
    void increment(int Int_Input_1,int Int_Input_2)
    {
        a*=Int_Input_1+Int_Input_2;
        b*=Int_Input_1+Int_Input_2;
        c*=Int_Input_1+Int_Input_2;
    }
    void increment(int Int_Input_1,int Int_Input_2,int Int_Input_3)
    {
        a+=Int_Input_1;
        b+=Int_Input_2;
        c+=Int_Input_3;
    }
    void print()
    {
        cout<<a<<endl<<b<<endl<<c<<endl;
    }
};


NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

Arrange Items for Solar Vehicle (Id-1501)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1501

There are ‘n’ bags in a corner of a city and they have to be moved to the centre of the city by a solar vehicle. The vehicle starts shunting from morning, the vehicle can carry more load in the mornings than in the evening when sunlight would be dimmer. Given the details of items in the bag, sort the bag in descending so that the vehicle can safely carry it to the centre of the city. Use vector and map in STL. Also use the sort algorithm defined in STL.

Hint: Use total weight of bag as key and object of bag as value, insert total weight of each bag into a vector. Use STL sort algorithm to sort it and print the details of bag in order

Input Format

Number of bags ‘n’

Name of bag1

Number of types of items in bag1, ‘t’

Weight of item1 in bag1

Number of item1 in bag1

Weight of item2 in bag1

Number of item2 in bag1



Weight of itemt in bag1

Number of itemt in bag1



….

….

Name of bagn

Number of types of items in bagn, ‘t’

Weight of item1 in bagn

Number of item1 in bagn

Weight of item2 in bagn

Number of item2 in bagn



Weight of itemt in bagn

Number of itemt in bagn


Output Format

Print name of bags in sorted order.

Sorting must be done in descending order based on the weight of the bag


Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 

Example: <pre> Your Code </pre>

Code: C++

void bag :: get()
{
    cin>>name>>num_Of_Items;
    for(int i=0;i < num_Of_Items;i++)  
    cin>>item_Wt[i]>>item_Count[i];
}
void bag :: print()
{
    cout<<name<<"\n";
}
float bag :: compute()
{
    float total=0;
    for(int i=0;i < num_Of_Items;i++)  
    total+=item_Count[i]*item_Wt[i];  
    return(total);  
}  
void solar :: get()  
{  
    bag temp_bag;  
    cin>>num_Bags;
    for(int i=0;i < num_Bags;i++)
    {
        temp_bag.get();
        m1.insert(pair < float,bag > (temp_bag.compute(),temp_bag));
        v.push_back(temp_bag.compute());
    }
}
void solar :: sort_Vec()
{
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
}
void solar :: print_In_Order()
{
    for(vector < float > :: iterator i=v.begin();i!=v.end();i++)
    m1[*i].print();
}

NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

Find a Route (Id-1533)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1533

Rahul is fond of travelling and he visits cities and towns in the country whenever possible. All cities in the country are not connected to each other. Given the details of the cities that are connected to each city, source city from where he begins the travel and the destination city of the travel, design an algorithm and write a C++ code to list down the cities in the travel. Rahul must not visit a city more than once. When the destination city name is in the connected cities of the current city, chose it and complete the route. When the destination city name is not in the list of connected cities to current city and there are more than one city from the current city, he sorts the city names and include the first minimum city name that is not yet visited. For example, if the connection between the cities are given as follows, source city as A and destination city as F the list of cities in the travel are A, B, D and F.



City Connected Cities
A E, B
B D
C E,D
D F
E F


Use vectors, maps and algorithms such as sort, find in STL for implementation. Assume that the connection of cities is very simple and there is a path as described in the problem.

Input Format

Number of cities that are connected to other cities, ‘n’

Name of city1

Number of neighbouring cities for city1, ‘m’

First neighbouring city of city1

Second neighbouring city of city1



mth neighbouring city of city1



Name of cityn

Number of neighbouring cities for cityn, ‘m’

First neighbouring city of cityn

Second neighbouring city of cityn



mth neighbouring city of cityn



Output Format

Name of cities in the list


Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 

Example: <pre> Your Code </pre>

Code: C++

void travel::get()
{
cin>>num_Of_Cities;
for(int i=0;i<num_Of_Cities;i++)
 {int x;
 string temp1;
 cin>>temp1>>x;
 for(int j=0;j<x;j++)
 {string temp;
 cin>>temp;
 city_Connection[temp1].push_back(temp); 
 }
 }
cin>>source>>destn;
}
void travel::find_Route()
{
route.push_back(source);
while(route.back()!=destn)
{
 bool flag=true;
 vector<string> store=city_Connection[route.back()];
 sort(store.begin(),store.end());
 if(find(store.begin(),store.end(),destn)!=store.end())
 {route.push_back(destn);break;}
 for(int i=0;i<store.size();i++)
 if (find(route.begin(),route.end(),store[i])==route.end())
 {route.push_back(store[i]);flag=false;break;}
}
}
void travel::print_Route()
{
for(int i=0;i<route.size();i++)
 cout<<route[i]<<endl;
}

NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

Snakes and Ladders (Id-1144)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1144

Snakes and Ladders is an ancient Indian board game. It is played between two or more players on a gameboard having numbered, gridded squares (which is in the form a matrix). The board has a number of pictures of the “ladders” and “snakes” on the board, each connecting two specific board squares. The object of the game is to navigate one’s game piece, according to die rolls, from the start (bottom square) to the finish (top square), helped or hindered by ladders and snakes respectively.

Given an m X n board, details of snakes and ladders in the board, current position of coin of player1 and sequence of dice rolls by player1, design an algorithm and write a C++ code to find the new position of coin of player1. The grids of the board are numbered from 1 to m*n. After a die roll, if the coin ends up in a square with snake / ladder start position then update position to end position of snake / ladder. Each grid in the board is given a number ‘g’ which is computed as (r-1)*n + c, where ‘r’ and ‘c’ are the row and column position of the grid.

Understand the template code and implement the functions appropriately

Input Format

Value for ‘m’

Value for ‘n’

Number of snakes in board k

Start Grid position of snake1

End Grid position of snake1

Start Grid position of snake2

End Grid position of snake2

….

Start Grid position of snake-k

End Grid position of snake-k

Number of ladders in board t

Start Grid position of ladder1

End Grid position of ladder1

Start Grid position of ladder2

End Grid position of ladder2

….

Start Grid position of ladder-t

End Grid position of ladder-t

Current row position of coin of player1

Current column position of coin of player1

Number of dice rolls

Value of roll1

Value of roll2



Value of roll-n

Output Format

Final row position of player1

Final column position of player1

Boundary Conditions

Assume that there will be only a maximum of ten ladders and ten snakes

The position will never go out of the board


Please Comment Working if the code worked to you
If you have other working codes please comment the codes enclosing with <pre> and </pre> 
Example: <pre> Your Code </pre>

Code: C++


NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

Row Maximum of a Matrix (Id-1246)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]


Just for Practice 2 Additional [3-Jan-2018 to 10-Apr-2018]

Program ID- 1246

Given an nXn matrix with entries as numbers, write an algorithm and C program to print the maximum value in each row of the matrix.

Input Format:

Value of ‘n’

Element in first row first column

Element in first row second column

..

Element in the first row n-th column

Element in second row first column

Element in second row second column

..

Element in the second row n-th column



Element in nth row first column

Element in nth row second column

..

Element in nth row n-th column

Output Format:

Maximum value in the first row

Maximum value in the second row



Maximum value in the n-th row

Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 

Example: <pre> Your Code </pre>

Code: C++

#include<stdio.h>
int main()
{
    int n,i,j;scanf("%d",&n);
    int A[n][n];
    for (i=0;i<n;i++)
    {
        for (j=0;j<n;j++)
        {
            scanf("%d",&A[i][j]);
        }
    }
    for (i=0;i<n;i++)
    {
        int temp=0;
        for (j=0;j<n;j++)
        {
           if (temp<A[i][j]){temp=A[i][j];} 
        }
        printf("%d\n",temp);
    }
}

NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

Computing Area of Different Shapes (Id-1326)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Just for Practice 4 Additional [8-Jan-2018 to 31-Mar-2018]

Program ID- 1326

The area is the two-dimensional amount of space that an object occupies. Area is measured along the surface of an object and has dimensions of length squared; for example, square feet of material, or centimetres squared.
The area of a rectangle is equal to the height h times the base b; A = h * b
The equation for the area of a trapezoid is one half the sum of the top t and bottom b times the height h; A = h * [ t + b ] / 2
The area of a circle is A = pi * r2, where pi = 3.14 and r = radius.
Develop a program in C++ using function overloading for computing the area of a rectangle, a trapezoid and a circle by a common function name ComputeArea() with different signature. Assume pi = 3.14. Print only two decimal places for all areas.
Note:
To print only two decimal places of a variable ‘a’, do the following:
#include<iomanip>
cout<<fixed<<setprecision(2)<<a;

Input Format:

Read the base and height of a rectangle.
Read the top, bottom and height of a trapezoid.
Read the radius of a circle.

Output Format:

Display the area of a rectangle, trapezoid and circle each in one line

Boundary Conditions:

You can give any valid integer or float values for inputs.

Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 

Example: <pre> Your Code </pre>

Code: C++

#include<iostream>
using namespace std;
#include<iomanip>
float area(float a, float b=0, float c=0)
{
    double area;
    float pi=3.14;
    if(b==0 && c==0)
    area=pi*a*a;
    else if(c==0)
    area=a*b;   
    else
    area=c*(a+b)/2;
    return area;
}

NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

Code Detection Problem (Id-1529)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1529

For security reasons, messages are transmitted as a secret code over a transmission channel. It is usually sent as a sequence of bits, that is, 0s and 1s. Due to noise in the transmission channel, the transmitted message may become corrupted. That is, the message received at the destination may not be the same as the message transmitted. There are several techniques to check the validity of the transmitted message at the destination. One such technique is to transmit the same message twice. At the destination, both copies of the message are compared. Given a file “data.txt” with the messages that is transmitted, write a C++ program to check whether the message received at the destination is error-free. For simplicity, assume that the secret code representing the message is a sequence of digits(0 to 9) and the maximum length of the message is 250 digits. Each original message is followed by a copy message and first number in both the messages indcates the length of the message. Each character in the message is separated by a space. For example, 7 9 2 7 8 3 5 6 7 9 2 7 8 3 5 6 means that the original message is of length 7 and it is 9 2 7 8 3 5 6 and copy message is also of length 7 and it is 9 2 7 8 3 5 6. If orginal and copy message is same then print Message transmitted is ok. Print Message transmitted is not OK when th length of the original or copy message is greater than 250 or when the original message is not same as copy message.

Input Format:

Name of the file
Input file contains a number of secret codes immediately followed their copy

Output Format:

Print either Message transmitted is ok or Message transmitted is not ok


Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 

Example: <pre> Your Code </pre>

Code: C++

#include<iostream>
#include<fstream>
#include<string>
#include<stdlib.h>
using namespace std;

main() {
    ifstream f;
    char strg[10], c[3];
    char l[5], l0[5];
    int num1,num2;
    string a, b;
    cin>>strg;
    f.open(strg);
    while(f) {
        a="";
        b="";
        f>>l;
        num1=atoi(l);
        num2=num1;

        if(num1==250) {
            cout<<"Message transmitted is not"<<endl;
            continue;
        }

        while(f && num1--) {
            f>>c;
            a.append(c);
        }
        f>>l0;
        num1=atoi(l0);

        if(num1==250 || num1!=num2) {
            cout<<"Message transmitted is not"<<endl;
            continue;
        }

        while(f && num1--) {
            f>>c;
            b.append(c);
        }

        if(a!="") {
            if(a==b) {
                cout<<"Message transmitted ok"<<endl;
            }
            else {
                cout<<"Message transmitted is not ok"<<endl;
            }
        }
    }
}

NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

Automatic vending machine (Id-1143)

Just for Practice 3 Additional [8-Jan-2018 to 31-Mar-2018]

Program ID- 1143

An automatic vending machine has many snack items arranged in its shelves. Each item has an item code and a cost. A user can enter the amount and key-in the item code. If the itemcode matches an entry in the item list and amount entered by user is less than cost of the item, then the item will be dispensed. Develop an algorithm and write a C++ code to print name of the item if the amount entered is greater than the cost of the item and item code is valid. If the amount is less than the cost of the item then throw a double exception, if the item code entered is wrong then throw a integer exception and when the item entered is not in stock throw a string exception. Print appropriate messages such as “Insufficient amount”, “Wrong item code” or “Less stock”.

Input Format:

Enter the number of items in the vending machine

Itemcode-1

Cost of item1

stock in hand item1

Itemcode-2

Cost of item2

stock in hand item2



Itemcode-n

Cost of item1

stock in hand item3

Item code entered by user

Cost entered by user

Output Format:

Print either item name or “Insufficient amount” or “Wrong item code” or “Less Stock”

Boundary Conditions:

Number of Item  >1

Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 

Example: <pre> Your Code </pre>

Code: C++

#include<iostream>
using namespace std;
class machine
{
    private:
    int code,stock,cost;
    public:
    int get()
    {
        cin>>code>>cost>>stock;
    }
    int display(int x, int y)
    {
        if(code==x)
        {
            if(stock!=0)
            {
                if(y>cost)
                {
                    cout<<code;
                    return 1;
                }
                else
                {
                    cout<<"Insufficient amount";
                    return 1;
                }
            }
            else
            {
                cout<<"Less Stack";
                return 1;
            }
        }
        else
        return 0;
    }
};

int main()
{
    int n,i,j=0,k=0,cost1,code1;
    cin>>n;
    machine s[n];
    for(i=0;i<n;i++)
    {
        s[i].get();
    }
    cin>>code1>>cost1;
    for(i=0;i<n;i++)
    {
        if(j==0)
        {
            j=s[i].display(code1,cost1);
            k++;
        }
    }
    if(k==n)
    cout<<"Wrong item code";
}

NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

Generic Double Ended Queue

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 

Design a generic class queue to maintain a list of elements. Queue is a linear data structure that follow FIFO ordering of elements. It is a special kind of list where elements can be inserted at one end and deleted at the end. There are two end points called front and rear. Front is the point of deletion and that move for each deletion but always points to the element that was inserted first among the elements remaining in the queue. Rear is the point of the insertion and move for each insertion but always points to the element that was inserted last among the elements remaining in the queue. Provide member functions to check if a queue is empty, queue is full, enqueue and dequeue.

Code: C++

#include<iostream>
#include<string>
using namespace std;

bool ERR_Flag = false;
template<class T>
class queue
{
protected:
    int front;
    int rear;
    int capacity;
    T *ele;
public:

    queue();
    bool isempty();
    bool isfull();

    bool enqueue(T data);

    T dequeue();
    ~queue();
    void print();
};
template<class T>
class deque:public queue<T>
{
public:
    bool push_Back(T data);
    bool push_Front(T data);
    T pop_Front();
    T pop_Back();
};

//start
template<class T> queue<T>::queue() {
    front=-1;
    rear=-1;
    capacity=20;
    ele=new T[20];
}
template<class T> bool queue<T>::isempty() {
    if(front==-1)
        return true;
    else
        return false;
}
template<class T> bool queue<T>::isfull() {
    if(rear==19)
        return true;
    else
        return false;
}
template<class T> bool queue<T>::enqueue(T data) {
    if(isfull())
        return false;
    else {
        ele[++rear]=data;
        if(!rear)
            front++;
        return true;
    }
}
template<class T> T queue<T>::dequeue() {
    if(isempty()) {
        ERR_Flag=true;
        return ele[0];
    }
    else {
        int i=front;
        if(front+1>rear) {
            rear=-1;
            front=-1;
        }
        else
            front++;
        return ele[i];
    }
}
template<class T> void queue<T>::print() {
    if(!isempty()) {
        for(int i=front; i<=rear; i++)
            cout<<ele[i]<<endl;
    }
    else
        cout<<"Queue is empty"<<endl;
}
template<class T> queue<T>::~queue() {}
template<class T> bool deque<T>::push_Back(T data) {
    return queue<T>::enqueue(data);
}
template<class T> bool deque<T>::push_Front(T data) {
    if(!queue<T>::isfull()) {
        if(queue<T>::isempty()) {
            queue<T>::enqueue(data);
        }
        else {
            for(int i=queue<T>::rear++; i>=queue<T>::front; i--)
                queue<T>::ele[i+1]=queue<T>::ele[i];
            queue<T>::ele[queue<T>::front]=data;
            return true;
        }
    }
    return false;
}
template<class T> T deque<T>::pop_Front() {
    return queue<T>::dequeue();
}
template<class T> T deque<T>::pop_Back() {
    if(!queue<T>::isempty()) {
        if((queue<T>::rear)-1>=(queue<T>::front))
            return queue<T>::ele[queue<T>::rear--];
    }
    else
        return queue<T>::ele[0];
}

int main()
{
    int d_Choice;
    int op_Choice;
    deque<string> d;
    queue<int> q;
    cin>>d_Choice;
    if(d_Choice==1)
    {
        while(1)
        {
            cin>>op_Choice;
            if(op_Choice==1)
            {
                if(q.isempty())
                    cout<<"Queue is empty"<<endl;
                else
                    cout<<"Queue is not empty"<<endl;
            }
            else if(op_Choice==2)
            {
                if(q.isfull())
                    cout<<"Queue is full"<<endl;
                else
                    cout<<"Queue is not full"<<endl;
            }
            else if(op_Choice==3) {
                int data;
                cin>>data;
                if(!q.enqueue(data))
                    cout<<"Queue full insertion not possible";
            }
            else if(op_Choice==4)
            {
                q.dequeue();
                if(ERR_Flag)
                    cout<<"Queue is empty";
            }
            else if(op_Choice==5)
            {
                q.print();
            }
            else if(op_Choice==6)
                break;
        }
    }
    else if(d_Choice==2)    {
        string s_Data;
        while(1)
        {
            cin>>op_Choice;
            if(op_Choice==1)
            {
                if(d.isempty())
                    cout<<"Queue is empty"<<endl;
                else
                    cout<<"Queue is not empty"<<endl;
            }
            else if(op_Choice==2)
            {
                if(d.isfull())
                    cout<<"Queue is full"<<endl;
                else
                    cout<<"Queue is not full"<<endl;
            }
            else if(op_Choice==3)
            {
                cin>>s_Data;
                if(!d.push_Back(s_Data))
                    cout<<"Queue full insertion not possible";
            }
            else if(op_Choice==4)
            {
                cin>>s_Data;
                if(!d.push_Front(s_Data))
                    cout<<"Queue full insertion not possible";
            }
            else if(op_Choice==5)
            {
                d.pop_Back();
                if(ERR_Flag)
                    cout<<"Queue is empty";
            }
            else if(op_Choice==6)
            {
                d.pop_Front();
                if(ERR_Flag)
                    cout<<"Queue is empty";
            }
            else if(op_Choice==7)
                d.print();

            else if(op_Choice==8)
            {
                break;
            }
        }
    }
}

NOTE: The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.