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

Create a class ‘Book’. Derive two classes from it namely ‘’Print_Book’ and

‘E_Book’. Store the following details about the book in the relevant classes.

Title, Author, Price, No of pages and Size in KB.

Input information for ‘m’ number of print books and ‘n’ number of eBooks and

display it.


WAP to create a class which stores a dynamic integer array and its size. Include all

the constructors and destructor in the class. Store two arrays of different size in

two objects. Join the two arrays and and store it in another object using a member

function.


Develop a program and algorithm to find the roots of the quadratic equation using bisection method.


Given a string on one line, a second string on a second line, and an integer index, insert the contents of the second string in the first string at the index specified. Then, output the result.

Ex: If the input is:

FuzzyBear

Wuzzy

5

the output is:

FuzzyWuzzyBear

Note: Using a pre-defined string function, the solution can be just one line of code.


#include <iostream>

#include <string>

using namespace std;


int main() {

string workStr;

string otherStr;

int strPos;


getline(cin, workStr);

getline(cin, otherStr);

cin >> strPos;


cout << workStr << endl;

return 0;

}


WAP to create the classes as per the hierarchy shown below.Include the data

members in the relevant classes to store the following information:-

Name, Id, No of matches played,No. of runs scored, No. of wickets taken.

Calculate the batting average and wickets per match for an all rounder player.Use

parameterized constructor to initialize the object.

[ Batting average=No. of runs scored/No. of matches played

Wickets per match= No. Of wickets taken/ No. of matches played ]


An arrayList is one of the most important data structures used in many applications. Define and show the implementation of the functions of an arrayList


Write a program that computes the value of the expression: lim(x->inf)(1+1/n)n

between certain values of n and then compare the values with e.

For example, you can compute the values of the expression between:

  • 100 and 10,000 with an increment of 100
  • or between 1,000 and 1,000,000 with an increment of 1,000.

The program should accept as input:

  1. The start value for n
  2. The end value for n

(Note: The increment value of 100 should be hardcoded in the program upon final submission.)

The program should then output the value of the expression for each value of n in the specified range with a decimal precision of 8.


Bianca is preparing special dishes for her daughter’s birthday.

It takes her a minutes to prepare the first dish, and each following dish takes b minutes longer than the previous dish. She has t minutes to prepare the dishes.

For example, if the first dish takes a = 10 minutes and b = 5, then the second dish will take 15 minutes, the third dish will take 20 minutes, and so on.

If she has 80 minutes to prepare the dishes, then she can prepare four dishes because 10 + 15 + 20 + 25 = 70.

Write a program that prompts the user to enter the values of ab, and t, and outputs the number of dishes Bianca can prepare.


Suppose you have two arrays: a1[0…n-1] of size n and a2[0….m-1] of size m. Write a program that checks whether a2[] is a subset of a1[] or not. Both the arrays may or may not be sorted. It can be assumed that elements within an array are distinct. 


Write a program that inputs a string value from the user and displays it in reverse using pointer. 


LATEST TUTORIALS
APPROVED BY CLIENTS