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

✓ Write a class Sum. Two data members q and r are declared in class Sam. The data members q

and rare initialized in a constructor

✓ Create a function In() to input the values of q and r. Also create a function Display() to the input values. Create a function to overload the binary addition operator to add two values.

display

✓ In main function create three objects m,n and o.

✓ Through mand o objects access the member function In() to input data twice. ✔ Now add these values from mand o and save in n. (Hint: n=m+o)

✔ Again through m, n and o objects access the member function Display() to display data

✔Show the output of program.

a program where customers can buy a certain packets of Chips and Apples when they are still available. for each transaction the user must enter the number of packets of one type to buy. if that number is still available, subtract it from the total packets still available. Use a sentinel to terminate the loop.


Provide an improved declaration for the Customer class that exploits the principles of reusability. Provide the interface only. (b) Implement the constructor for the derived Customer class. (c) Consider the partial class declaration of an Employee class below: class Employee: protected Person{ public: //... double Rate; double GetRate() const; double GetHours() const; private: double Hours; //... protected: double Pay() const; //... }; (i) The code fragment below (extracted from a main() function) has three invalid statements. Write down the line numbers of the invalid statements and explain why each of these statements is invalid. E is an instance of an Employee object.
Write strassen matrix multiplication for nxn matrix in c++.

Write a program to print all the LEADERS in the array. An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. For example in the array {16, 17, 4, 3, 5, 2}, leaders are 17, 5 and 2.


Use the following driver program to test your classes InsurancePolicy and CarInsurance:
#include <iostream> #include <fstream> #include "Insurance.h" #include "CarInsurance.h" using namespace std;
int main() {InsurancePolicy myPolicy(123456, "Peter Molema", 3450.67);
CarInsurance yourPolicy(456891, "Wilson Ntemba", 5550.67,
15000.00);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
myPolicy.showPolicy(cout);
cout << endl;
yourPolicy.showPolicy(cout);
cout << endl << "AFTER UPDATES:" << endl;
myPolicy.setPolicy(123456, "Peter Molema", 5450.67);
yourPolicy.setPolicy(456891, "Wilson Ntemba", 6650.67,
25000.00);
myPolicy.showPolicy(cout);
cout << endl;
yourPolicy.showPolicy(cout);
cout << endl;
return 0;
}

2. Write a C++ program to show the sorting methods based on user input with the explanation. You can choose any TWO (2) of the sorting methods as below.


- Selection

- Insertion

- Merge

- Bubble

- Quick


  1. Write a C++ program to show the implementation of the Binary Search Tree using a linked list. The program must include all the operations in Binary Search Tree with explanation including:
  • creating BST
  • inserting an item into BST
  • display item in BST
(a) Write a function called count to determine the number of times a specific value
occurs in a vector of integers. The function should receive two parameters: the
vector to be searched (v) and the value to search for (val). count should return
the number of times val occurs in vector v.
Test your function count in a program by declaring a vector and initializing it, and
then call function count to determine how many times a specific value occurs in
the vector.
(b) Write a template version of the function count to determine the number of times
a specific value occurs in a vector of any base type and test it by declaring two
or more vectors with different base types and determining how many times a
specific value occurs in these two vectors.

Write a C++ program to declare an integer array of 50 elements. Fill this array using random function with values in range -25 to +75. Now, print address(s) of only those indexes which are having a value which is a prime No.


 


LATEST TUTORIALS
APPROVED BY CLIENTS