Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please complete the following C++ programs on paper or without using Visual Studio, and be sure to use the correct solution. I wanted to learn

Please complete the following C++ programs on paper or without using Visual Studio, and be sure to use the correct solution. I wanted to learn who isthe the program is solved.

1. Consider the following function:

int mystery(int num1, int num2)

{

if (num1 > 0)

{

for (int i = 1; i <= num1; i++)

num2 = num2 * i;

return num2;

}

else if (num2 > 0)

{

for (int i = 0; i <= num2; i++)

num1 = num1 + i;

return num1;

}

return 0;

}

What is the output for the following statement in the main function?

cout<< mystery(-3, 4) << endl;

2. Consider the following function:

int mystery(int num1, int num2)

{

if (num1 > 0)

{

for (int i = 1; i <= num1; i++)

num2 = num2 * i;

return num2;

}

else if (num2 > 0)

{

for (int i = 0; i <= num2; i++)

num1 = num1 + i;

return num1;

}

return 0;

}

What is the output for the following statement in the main function?

cout<< mystery(4, -5) << endl;

3. Given the following function:

int next(int x) { return (x + 1); } what is the output of the following statement? cout << next(next(5)) << endl;

4. Given the function prototype: double testAlpha(int u, char v, double t); which of the following statements is legal?

a.

cout << testAlpha('5.0', 'A', '2.0');

b.

cout << testAlpha(5, 'A', 2);

c.

cout << testAlpha(5.0, "65", 2.0);

d.

cout << testAlpha( int 5, char 'A', int 2);

5. The following function heading in a C++ program is valid: int functnExp(int u, char v, float g)

True

False

6. Which of the following function prototypes is valid?

a.

int funcTest(int x, int y, float z);

b.

int funcTest(int, int y, float z)

c.

funcTest(int x, int y, float){};

d.

int funcTest(int x, int y, float z){}

The following is instruction you gonna solve using Visual Studio.

  1. Program named Lab13B that will calculate fines for overdue books at the library.
  2. include or build a double function named computeFine that accepts 2 integer parameters for the number of books and the number of days overdue. It should calculate the fine based on the following: $0.10 per day per book and return that fine.
  3. In the main function
    1. Ask the user for the number of books and the number of days they are overdue.
    2. Call the computeFine function to get the fine. (Place the returned value into a variable.)
    3. Print the fine with a label (and 2 decimal places.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions