C++ Answers

Questions answered by Experts: 9 913

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

1, For each loop with example

2, do while loop with example


Two cars A and B leave an intersection at the same time. Car A travels west at an average speed of x


miles per hour and car B travels south at an average speed of y miles per hour. Write a program that


prompts the user to enter the average speed of both the cars and the elapsed time (in seconds) and


outputs the total distance each car has traveled as well as the shortest distance between the cars.


Output data MUST be rounded to 2 decimal places and have precision set so that all data is evenly lined


up. For simplicity, assume that decimal numbers will be no more than 8 digits long.



Decision and repetition statement with example

1,If statement

2,switch statement

3,for loop,for each loop

4,while loop, do while loop


You are to write a code that simulates the working of a Cosmetic Store which has a small sales team.
The store pays commissions to each member of its sales team every six months. The commission is
based on the total sales generated by each employee and their position in the company. You need to
design a code that calculates and compares the commissions earned by every member of the sales
team and also clearly identifies the sales team member earning the highest commissions.

Create a base class called Shape with two data members of double type

which could be used to compute the area of figures. Derive two specific

classes called Triangle and Rectangle from the base class Shape. Add to the

base class, a member function called GetData to initialize base class data

members and another member function displayArea to compute and display

the area of figures. Make displayArea a virtual function and redefine this

function in the derived classes to suit their requirements. Using these three

classes design a program which will accept dimensions of a triangle or

rectangle interactively and display the area.


Write a program to create a class called STUDENT with data members Roll

Number, Name and Age. Using inheritance, create the classes

UGSTUDENT and PGSTUDENT having fields a semester, fees and

stipend. Enter the data for at least 5 students. Find the average age for all

UG and PG students separately.


(Hierarchical Inheritance):-

Derive a class named as CYLINDER from CIRCLE class. Take necessary

data & member functions for this class to calculate the volume of the

cylinder. Show the result by accessing the area method of circle and

rectangle through object of rectangle class and the area of circle and volume

method of cylinder class through the objects of cylinder class.


(Multilevel Inheritance):-

Derive a class named as BOX from RECTANGLE class. Take necessary

data & member functions for this box class to calculate the volume of the

box. All the data members are initialized through the constructors. Show the

result by accessing the area method of circle and rectangle and the volume

method of box class through the objects of box class.


(Single Inheritance) Write a program to create a class CIRCLE with one

field as radius, used to calculate the area of a Circle. Create another class

RECTANGLE used to calculate the area of the rectangle which is a subclass

of CIRCLE class. Use the concept of single inheritance such that the radius

of circle class can be re-used as length in rectangle class. Take necessary

data members and member functions for both the classes to solve this

problem. All the data members are initialized through the constructors.

Show the result by accessing the area method of both the classes through the

objects of rectangle class.


Write a program to implementation a Queue using stacks.
(You may follow the link for hint: https://www.geeksforgeeks.org/queue-using-stacks/)
LATEST TUTORIALS
APPROVED BY CLIENTS