Question

If a function needs to return more than one value, as a rule of good programming...

If a function needs to return more than one value, as a rule of good programming style, you should change it to a(n) ____________________ function and use the appropriate reference parameters to return the values.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If a function needs to return more than one value, as a rule of good programming style, you should change it to a(n) call by reference function and use the appropriate reference parameters to return the values.

Let me give a brief idea about what do we mean by pass by reference function. Instead of passing the value of the variables, we pass the address of the variable in the function, so when the function uses the variable, it goes to the address of the variable and modifies the value of the variable. This is a good technique when we need to manipulate from inside a function the value of an external variable. When we need to return more than one values we pass the reference of the variables and then modify the value at the address, so then more than one values can be returned.

Add a comment
Know the answer?
Add Answer to:
If a function needs to return more than one value, as a rule of good programming...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming plse help Reference parameters are useful when wanting to return more than one value True...

    Programming plse help Reference parameters are useful when wanting to return more than one value True False What do we call the parameters that would fit the red circle? functionName(); manipulative parameters referred parameters syntax parameters actual parameters Value-returning functions such as into 0 and bool 0 must return a value to stop True False

  • C programming Write a function that goes through all elements of an array of size n,...

    C programming Write a function that goes through all elements of an array of size n, and output the minimum and maximum values using pointers. Since C functions can only return one value, you must use pointers to output the minimum and maximum values from the function. You are not expected to print the values on the screen. Note: you will be assessed on the functionality and the coding style.

  • C++ Programming: Write a function that takes in a C++-style string s (from #include ), as...

    C++ Programming: Write a function that takes in a C++-style string s (from #include ), as well as an integer n, and then returns true if any substring of length n in s repeats itself, and false otherwise. For example, if s is "toe-to-toe" and n is 3, then the function would return true since "toe" occurs twice within s. However, if n were 4, the function would return false. As a second example, if s is "singing" and n...

  • C programming Write a function that accepts an array of integers as an input, and output...

    C programming Write a function that accepts an array of integers as an input, and output the sum of all values and the multiplication of all values. e.g. Suppose that the array contained the following values: 1 2 3 -4 5. The function should calculate and output the sum of values (i.e. 1+2+3+(-4)+5=7) and the multiplication of all values (i.e. 1*2*3*-4*5=-120). Start by carefully writing the function prototype - put some thought into this. Think about the good programming habits,...

  • THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #inclu...

    THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #include "pch.h" #include #include using namespace std; // Function prototype void displayMessage(void); void totalFees(void); double calculateFees(int); double calculateFees(int bags) {    return bags * 30.0; } void displayMessage(void) {    cout << "This program calculates the total amount of checked bag fees." << endl; } void totalFees() {    double bags = 0;    cout << "Enter the amount of checked bags you have." << endl;    cout <<...

  • PHP Programming Question. Use the techniques you learned so far to create an Address Book application...

    PHP Programming Question. Use the techniques you learned so far to create an Address Book application that stores names, e-mail addresses, and phone numbers in a text file. Validate all input fields and include functionality that allows the user to view the address book. Also, include code that sorts the address book by name and deletes duplicate entries. Each page in the application should have a link back to the main page. Be creative and add extra features if you...

  • Use c++ as programming language. The file needs to be created ourselves (ARRAYS) Write a program...

    Use c++ as programming language. The file needs to be created ourselves (ARRAYS) Write a program that contains the following functions: 1. A function to read integer values into a one-dimensional array of size N. 2. A function to sort a one-dimensional array of size N of integers in descending order. 3. A function to find and output the average of the values in a one dimensional array of size N of integers. 4. A function to output a one-dimensional...

  • solve part B Note: Do not use MATLAB (or other programming languages) build-in functions for regression....

    solve part B Note: Do not use MATLAB (or other programming languages) build-in functions for regression. (a) Write a MATLAB (or other programming languages) function that accepts n values of xi and Yi, perform Linear Regression and returns values of rand, the model parameters ao and a. (6) Write another MATLAB (or other programming languages) function that accepts n values of X, and y(provided as arrays), checks for Linear, Power (y = axBx) and Saturation growth- rate (y = a*)...

  • Programming in C (using only #include <stdio.h>) 1. Create and use a new function called average....

    Programming in C (using only #include <stdio.h>) 1. Create and use a new function called average. 2. Average will accept two integer arguments, (here I will name them sum and n). n is the count of values included in sum. 3. The function will return the integer average of sum. 4. Define and use a function that checks an integer to see if it is positive (returns true if the integer is positive) Note: Choosing proper definition attributes (names, arguments,...

  • MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demo...

    MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT