Question

In: Computer Science

Write in C++ Print the following heading (should be in heading function) Welcome to Reference parameters...

Write in C++

Print the following heading (should be in heading function)

Welcome to Reference parameters

2 ) ask the user for 2 numbers (should be in main)

3 ) Calculate the sum and product of the numbers using reference parameters (should be in getAnswer function)

4 ) Print the sum and product of the numbers in the following format: (should be in printmessage function)

Here is the function you need       

Function name | Parameters                       | Return Type   

heading | N/A | void

getAnswer | lnumber1, number2, sum, product | void

printmessage | sum, product | void

Sum: <sum>

Product: <product>

Example:

Enter a number: 5

Enter another number: 2

Sum: 7

Product: 10

Solutions

Expert Solution

please refer to bleow attached photos for clear understandign and implementation of the program :

code :

#include <iostream>
using namespace std;

void getAnswer(int a , int b , int &product , int &sum){
    sum = a + b;
    product = a * b;
}

void printmessage(int sum , int product){
    cout<<"Sum : "<<sum<<endl;
    cout<<"Product : "<<product<<endl;
}

int main(){
    int a,b,sum,product;
    cout<<"Enter one number : ";
    cin>>a;
    cout<<"\nEnter another number : ";
    cin>>b;
    
    getAnswer(a , b , product , sum);
    printmessage(sum , product);
}

Related Solutions

In C++ Instructions: Use a void function to print the following message (should be in welcome...
In C++ Instructions: Use a void function to print the following message (should be in welcome function) Welcome to the Event Scheduling program create 3 int arrays with 3 positions (one array for days one array for moths and one array for years) (should be in main) Create a file that contains the following (you can just create the file or write the file in the program) 1 / 26 / 2021 12 / 13 / 2020 2 / 1...
Write a function that will accept two integer matrices C and D by reference parameters. The...
Write a function that will accept two integer matrices C and D by reference parameters. The function will compute the transpose of C and store it in D. For your information, the transpose of matrix C is D, where D[j][i] = C[i][j]. [7 marks] Explain the time complexity of this function inside of the function code as a comment. [3 marks] in C++
C++ Write the implementation of the function concatenateIntArrays. This function receives 4 parameters in the following...
C++ Write the implementation of the function concatenateIntArrays. This function receives 4 parameters in the following order: An array of integer values (array1). An integer representing the size of array1 (size1). An array of integer values (array2). An integer representing the size of array2 (size). The function creates a dynamic array of integers of size size1+size2 to store all the values in array1, followed by all the values in array2. The function returns the pointer used to create the dynamic...
Even Odd Average (C++ LANGUAGE) Write the following functions: Function #1 Write the function Print. The...
Even Odd Average (C++ LANGUAGE) Write the following functions: Function #1 Write the function Print. The function will have one int 1D array n and one int size as parameters. The function will display all the values of n on one line. Function #2 Write the function AverageEvenOdd. The function will have one int 1D array n and one int size as parameters. The size of the array is given by the parameter int size. Therefore, the function should work...
Instructions (in C++): 1 ) Use a void function to print the following message (should be...
Instructions (in C++): 1 ) Use a void function to print the following message (should be in welcome function) Welcome to the Event Scheduling program 2 ) create 3 int arrays with 3 positions (one array for days one array for moths and one array for years) (should be in main) 3 ) Create a file that contains the following (you can just create the file or write the file in the program) 1 / 26 / 2021 12 /...
C language Modify the getAvg() function to support passing an array by reference. The parameters of...
C language Modify the getAvg() function to support passing an array by reference. The parameters of this function should be pointer to a float array, and the size of the array. Returns the average of the array. Build a function called getScoreFromUser() with the following properties: Asks the user to enter the score scans into a local float variable returns the float value that the user entered. Build and present a menu to a user like the following and enclose...
Write an overloaded function of function area with 3 (float) parameters. This function should calculate and...
Write an overloaded function of function area with 3 (float) parameters. This function should calculate and print out the product of the 3 parameters.
C++ Write the definition of a function minMax that has five parameters. The first three parameters...
C++ Write the definition of a function minMax that has five parameters. The first three parameters are integers. The last two are set by the function to the largest and smallest of the values of the first three parameters. The function does not return a value. The function can be used as follows: int a=31, b=5, c=19 big, small; minMax(a,b,c,&big,&small); /* big is now 31 */ /* small is now 5 */ **ONLY THE FUNCTION
Write a function in R named counts. This function should take as parameters a numeric vector...
Write a function in R named counts. This function should take as parameters a numeric vector x and also a number indicating a number of bins n. The function will consider the range [min(x),max(x)], and then consider a parti- tion of this interval into n non-overlapping equally sized half open intervals: I1 = [min(x),b1),I2 = [b1,b − 2),...,In = (bn−1,max(x)]. Note that since the intervals are equally sized, the value of bi is constrained. The function will then return a...
1.  Complete the second printSalutation() method to print the following given personName "Holly" and customSalutation "Welcome": Welcome,...
1.  Complete the second printSalutation() method to print the following given personName "Holly" and customSalutation "Welcome": Welcome, Holly End with a newline. What I am given: import java.util.Scanner; public class MultipleSalutations { public static void printSalutation(String personName) { System.out.println("Hello, " + personName); } //Define void printSalutation(String personName, String customSalutation)... /* Your solution goes here */ public static void main (String [] args) { printSalutation("Holly", "Welcome"); printSalutation("Sanjiv"); } } 2. Write a second convertToInches() with two double parameters, numFeet and numInches, that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT