Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
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 definition of a void function that takes as input two parameters of type int, say sum and testScore the function updates the value of sum by adding the value of testScore. The new value of sum is reflected in the calling environment.
The Issue: You have a function that accepts a variety of parameters. It is impractical to provide them as traditional parameters. So, what are you going to do?
How we can pass the function pointer as a parameter give example.

Chapter 5 Solutions

Problem Solving with C++ (9th 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