Posts

Showing posts from December 21, 2020

Write a C++ program to implement a suitable data structures (using array) of marble plates

Image
  Write a C++ program to implement a suitable data structures (using array) of marble plates. Your program should cover the following scenario, Suppose a waiter in a hotel is collecting plates from different tables and giving to dish washer. Dish washer is washing plates and throwing them into rack of plates. Some plates hit others very hard to break other (one above it) and/or itself. You need to develop an application that will find how many plates are broken and plates from which tables are broken. You will identify plates with unique numeric identity number. Every 5 th plate thrown into rack will break itself and one plate below it while every 7th plate will only break itself. Answer: #include "stdafx.h" #include "iostream" #include "conio.h" using namespace std; class Dishwasher { private :       int data[10];       int top;       int bottom;       int size; public :      Dishwasher() {            top = -1;            bottom = 0;        

Write a program that will take 10 integer values from the user. a. If the entered value is Even then enqueue it into a queue at even index and if the entered value is Odd then enqueue it into a queue at odd index. (Note: Even index will start from 0 & odd will start from 1 ). b. Dequeue the values and display the sum of the even values and the sum of the odd values.

Image
  Write a program that will take 10 integer values from the user. a. If the entered value is Even then enqueue or link-list it into a queue at even index and if the entered value is Odd then enqueue it into a queue at odd index. (Note: Even index will start from 0 & odd will start from 1 ). b. Dequeue the values and display the sum of the even values and the sum of the odd values.   Answer: C++ code: #include "stdafx.h" #include "iostream" #include "conio.h"   using namespace std; struct queue {   int front, rear, size, data[10]; public :      int even_sum = 0;      int odd_sum = 0;      queue()      {            front = 0;            rear = -1;            size = 10;      }      void enqueue( int x )      {            if (rear == 9)            { cout << "Queue is full no more elements can be insert" << endl;            }            else            {