Question: A. Write a short C++ program that performs the following tasks: 1. Declares variables 2. Prompts the user to enter two real numbers Reads the

A. Write a short C++ program that performs the following tasks:

1. Declares variables 2. Prompts the user to enter two real numbers Reads the real numbers from the keyboard if the second number is not zero

3. Formats the output to display the numbers in fixed format with one decimal digit

4. Prints their ratio on the screen along with the two values read from the file otherwise

5. Prints on the screen, "Cannot divide by zero"

Important: the ratio must be calculated by a value-returning function named ratio(). You must define the function ratio( ) below main( ). It receives two real numbers, divides the first number by the second one, and returns the result as real number. You do not need to round the result.

Example A:

Please enter two real numbers: _ If the values input are 5.0 and 2.5, the output should be:

Ratio 5.0/2.5 = 2.0 Note: include the prototype and the function definition in your solution.

B. Write a function that reads a whole number and a real number from the keyboard and returns them to the caller. The function must prompt the user to enter the two values.

Call the function twice from main() and display the values entered in both occasions. Show the real numbers with 2 decimal digits.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!