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 program that declares a structure to store book Id, price and pages of a book.
The structure should include functions to assign user defined values to each book and
display the record of most costly book.

The coordinates of a point are a pair of numbers that define its exact location on a two dimensional plane. Create a class named Coordinate that will represent a two dimensional point. Include two data fields for the x and y axis, a constructor that will require arguments to initialize the data values. Overload the + operator and - operator such that we can add, subtract, coordinates and return doubles, respectively. Write a main() that demonstrates that your class and function work correctly.


At the peak of COVID-19, most worker started working from home. Salaries of workers were reduced by 30%. Assuming income tax was also reduced by 50% from the previous rate of 15% and workers were paid on the number of hours worked in a month and each worker is supposed to work a total of 170 hours in a month. All overtime has been cancelled. If a worker does not meet the 170 hours’ threshold for a month, 5% is deducted from the salary. Assuming the hourly rate is GHC 10, Write a c++ program for the scenario narrated above. Your program should:

a) request for an employee’s name, the number of hours worked in a

month

b) define a function called payRole, your function should compute a

worker’s salary and income tax and any deductions if any

c) your program should display the results in “b” above.

d) explain the logic behind the code especially the function


Execute this code with THREE pushes and ONE pop stack s; s.push(1); s.push(2); s.push(3); cout << s.pop( ); Suppose that s is represented by a linked list. Draw the state of the private member variables of s after the above code:

_______

head_ptr | |

|_______|


Write a program to find the greatest of two given m two different classes using friend function.


WAP in C++ to find the biggest of three numbers using friend function.


WAP in C++ to find a Fibonacci scries using copy constructor.


Write following functions and demonstrate their working using a program.
1- Sum Function (takes two integer parameters and returns their sum)
2- Difference Function (takes two integer parameters and returns their difference)
3- Product Function (takes two integer parameters, performs division, returns product)
4- Quotient Function (takes two integer parameters, performs division, returns quotient)
5- Remainder Function (takes two integer parameters, performs division and returns remainder)

Write a function which takes two integers as parameter and return the largest number. Demonstrate the function using a program (call that function). Display the largest number in main function


Suppose that the input is 10 -6 12 -5 -4 0. What is the output of the following code?



int num;

int sum = 0;

cin >> num;

while (num != 0)

{

if (num>0)

sum = sum + num;

else

sum = sum - num;

cin >> num;

}

cout << ” Sum = ” << sum << endl;


LATEST TUTORIALS
APPROVED BY CLIENTS