Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
Question
Book Icon
Chapter 5.2, Problem 10STE
Program Plan Intro

void Functions:

  • A function must either return a single or no value at all.
  • A function that would not return a value is termed as “void” function.
  • The “void” function is been defined in same way as function that would return a value.
  • It implements only subtask for complete problem.
  • If a “void” function is called, formal parameters are substituted with arguments.
  • The statements in function body are executed.
  • The “return” statement specifies value that is been returned.

Call-by-Reference:

  • It is a method for substituting arguments.
  • The corresponding argument is substituted for formal parameter.
  • The argument for a function call might be a variable.
  • This argument variable is substituted for formal parameter.
  • It is similar to copying of argument variables into function definition body in place of formal parameter.
  • The code in function body is executed once argument is substituted.
  • This code can change argument variable value.
  • The ampersand sign (&) is attached to end of type name in formal parameter list in both function declaration as well as function header definition.

Call-by-value:

  • It copies the actual value of an argument into function’s formal parameter.
  • The changes made to parameter inside function have no effect on argument.
  • This method is used in default in programs.
  • The code within a function could not alter arguments used for calling function.

Blurred answer
Students have asked these similar questions
Write the function prototype of the void function named G() that takes an int reference parameter and two char parameters respectively Your answer
Write a definition for a void-function that has two int value parameters and outputs to the screen the product of these arguments. Write a main function that asks the user for these two numbers, reads them in, calls your function, then terminates. c++
In C++ Write the definition of a void function that has one double parameter and changes the sign of the parameter (if it is negative it becomes positive, and if it is positive it becomes negative)

Chapter 5 Solutions

Problem Solving with C++ (10th Edition)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning