Answer to Question #260883 in C++ for Maricar Algabre

Question #260883

SummaryIn this lab, you complete a partially written C++ program that includes a function named multiplyNumbers() that multiplies two int values to find their product.Three ints should be passed to the multiplyNumbers() function, the two numbers to be multiplied (num1 and num2) should be passed by value, and another int (product) to hold the product of the two numbers should be passed by reference, enabling the multiplyNumbers() function to change its value.The source code file provided for this lab includes the necessary variable declarations and input and output statements. Comments are included in the file to help you write the remainder of the program.Instructions:Open the source code file named MultiplyTwo.cpp using the code editor.Write the multiplyNumbers() function, the function declaration, and the function call as indicated by the comments.

1
Expert's answer
2021-11-04T05:05:48-0400

Declare the method prototype using:

void multiplyNumbers(int x, int y,int &product);

Call the function using:

multiplyNumbers(num1, num2,product);

Lastly, the method is as follows:

void multiplyNumbers (int x, int y,int &product) {
 product = x * y;
 return; }

Explanation:

Declare the method prototype using

void multiplyNumbers(int x, int y,int &product);

Call the function using

multiplyNumbers(num1, num2,product);

The method is as follows; the & written in front of product implies that product is passed by reference

void multiplyNumbers (int x, int y,int &product) {

This calculate the product

 product = x * y;

This returns nothing

 return; }

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS