Answered Essay: Prompt the user for two integers. The program then calculates the sum of the integers, the difference of the integers, the product of th

Prompt the user for two integers. The program then calculates the sum of the integers, the difference of the integers, the product of the integers, and the quotient with remainder of the integers. All of these math calculations are performed in one function. But how can a function return more than one value? By using formal parameters that are reference variables. In other words, pass the parameters by reference. 1. getData0 A void-returning function. The function prompts the user for two integer values. The function receives two integer arguments passed by reference to hold the values entered by the user. doTheMath0 A void-returning function adds, subtracts, multiplies, and divides the two integers as 2. described above. The function receives 7 arguments: numl - The first integer value from the user (pass by value). num2 - The second integer valuea from the user (pass by value). sum (pass by reference) difference (pass by reference) product (pass by reference) quotient (pass by reference) remainder (pass by reference) displayResults0 A void-returning function displays the results of the four math operations. The function receives the 7 arguments. The arguments are passed in the same manner as described in #2. Potential problem: If the user enters a value of zero for the second number, a problem arises with division (cannot divide by zero). If you dont handle the situation, your program will crash because the CPU will not allow division by zero Solution: Include code to prevent division by zero. If the second number is zero, then output should state: Cannot divide by zero Output when num 2 != 0: * Output when num2 == 0: Please enter two integer values: This statement is in the getData0 function. 12 Please enter two integer values: 90 Here are the results: The sum of 12 and 3 is 15 The difference, (12 minus 3) is9 The product of 12 and 3 is 36. 12 divided by 3 is 4 with a remainder of 0. Here are the results: The sum of 9 and 0 is 9 The difference, (9 minus 0)is 9 The product of 9 and 0 is 0. These statements are in the displayResults0 function Cannot divide by zero Press any key to continue */

Prompt the user for two integers. The program then calculates the sum of the integers, the difference of the integers, the product of the integers, and the quotient with remainder of the integers. All of these math calculations are performed in one function. But how can a function return more than one value? By using formal parameters that are reference variables. In other words, pass the parameters by reference. 1. getData() – A void-returning function. – The function prompts the user for two integer values. – The function receives two integer arguments passed by reference to hold the values entered by the user. 2. doTheMath() – A void-returning function adds, subtracts, multiplies, and divides the two integers as described above. – The function receives 7 arguments: a.) num1 – The first integer value from the user (pass by value). b.) num2 – The second integer valuea from the user (pass by value). c.) sum (pass by reference) d.) difference (pass by reference) e.) product (pass by reference) f.) quotient (pass by reference) g.) remainder (pass by reference) 3. displayResults() – A void-returning function displays the results of the four math operations. – The function receives the 7 arguments. – The arguments are passed in the same manner as described in #2. Potential problem: If the user enters a value of zero for the second number, a problem arises with division (cannot divide by zero). – If you don’t handle the situation, your program will crash because the CPU will not allow division by zero. Solution: Include code to prevent division by zero. If the second number is zero, then output should state: “Cannot divide by zero.” /* Output when num2 != 0: /* Output when num2 = 0: Please enter two integer values: This statement is in the getData() function. 12 Here are the results: The sum of 12 and 3 is 15. The difference, (12 minus 3) is 9. The product of 12 and 3 is 36. 12 divided by 3 is 4 with a remainder of 0. These statements are in the displayResults() function Please enter two integer values: 9 0 Here are the results: The sum of 9 and 0 is 9. The difference, (9 minus 0) is 9. The product of 9 and 0 is 0. Cannot divide by zero. Press any key to continue */

Expert Answer

 

here i have written the C++ program as per the requirement.I have also inclueded the comment for better understanding.

—————————————————————————————————————————————-

Note: Please note that the below program has been tested on ubuntu 16.04 system and compiled under g++ compiler. This code will also work on other IDE’s and Visual Studio C++ IDE. Just copy paste the code and execute.

——————————————————————————————————————————————

Program:

——————————————————————————————————————————————

//Header file declration

#include<iostream>

#include<stdlib.h>

//Namespace declration

using namespace std;

//getData function definition

void getData(int &num1, int &num2, int &sum, int &difference, int &product, int &quotient, int &remainder)

{

//input the numbers

cout<<“Please enter two integer values: “;

cin>>num1>>num2;

//performing the maths

sum = num1 + num2;

difference = num1 – num2;

product = num1 * num2;

//if num2 is not equal to zero
//then perform quotient and remainder operation

if(num2 != 0)

{

quotient = num1/num2;

remainder = num1 % num2;

}

}

//displayResult function definition

void displayResults(int &num1, int &num2, int &sum, int &difference, int &product, int &quotient, int &remainder)

{

cout<<“The sum of “<< num1 <<” and “<<num2<<” is “<<sum<<endl;

cout<<“The difference “<<” (“<<num1<<” minus “<<num2<<” ) is “<<difference<<endl;

cout<<“The product of “<< num1 <<” and “<<num2<<” is “<<product<<endl;

if(num2 != 0)

{

cout<<num1<<” divided by “<<num2<<” is “<<quotient<<” with a remainder of “<<remainder<<endl;

}

else

{

cout<<“can not divide by zero.”<<endl;

exit(0);

}

cout<<“Press any key to continue..”<<endl;

}

int main()

{

//variable data type declrations

int num1, num2, sum,difference, product, quotient, remainder;

//call to functions

getData(num1, num2, sum,difference, product, quotient, remainder);

displayResults(num1, num2, sum,difference, product, quotient, remainder);

return 0;

}//end of the main fucntion

——————————————————————————————————————————————-

here i have attached the output of the program as a screen shot…

————————————————————————————————————————————————–

Sample Output 1:

Sample Output: 2

————-

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.