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 12STE
Program Plan Intro

void Functions:

  • A function must either return a single or no value.
  • A function where no value is returned 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 argument is substituted for formal parameter.
  • The function call arguments may 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 function body code is been 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 actual value of an argument into function’s formal parameter.
  • The changes made to parameter inside function have no effect on argument.
  • This technique is used in default in programs.
  • The code within a function could not alter arguments that are used for calling function.

Program Plan Intro

void Functions:

  • A function must either return a single or no value.
  • 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 argument is substituted for formal parameter.
  • The function call arguments may 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 function body code is been 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 actual value of an argument into function’s formal parameter.
  • The changes made to parameter inside function have no effect on argument.
  • This technique is used in default in programs.
  • The code within a function could not alter arguments that are used for calling function.

Blurred answer
Students have asked these similar questions
Function Call Operator with code?
What is the difference between a formal parameter and an argument? Group of answer choices A function’s argument is referred to as the formal argument to distinguish it from the value that is passed in during the function call. The parameter is the passed value. A function’s parameter is referred to as the formal parameter to distinguish it from the value that is passed in during the function call. The argument is the passed value. A function’s parameter is used for passing by reference. The argument is used for passing by value. A function’s parameter is used for passing by value. The argument is used for passing by reference. They are identical but using different terms.
in c++, "Overload of functions" Write an overloaded function that returns a value based on a set of formal parameters: . z={        x - a;             x + a - b

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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education