Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 6, Problem 37RQE

Explanation of Solution

Function:

One of the building blocks of C++ program is functions; it contains a group of statements which are used to perform a specific task and the executable segments in a program.

  • The function “main()” is most import function in a program, because the “main()” function is the starting point of the program.
  • The main advantage of using function is reusability of code and reduces the size of the program, because a function can be called for multiple numbers of times.

Function call:

The statement which causes the function to execute is referred as function call.

  • The function is called by its function name and the return type should not be specified before the function call.
  • The semicolon should be given at the end of the function name.

Example:

//Function call

show();

In the above example, the function “show()” does not have the return type and it holds the semicolon at the end.

Function call for the given function:

The following function “getNumber()” uses the reference parameter variable which accepts an integer argument. It asks the user to enter the number and validates the entered number is in the range of 1 to 100. Finally, it stores input value in the parameter variable.

/* Function definition for a function "getNumber()" which uses the reference parameter variable which accepts an integer  argument */

void getNumber(int &x)

{

//Get the value from the user

cout << "Enter a number in the range 1 – 100 : ";

cin >> x;

//Check whether the given number is between 1-100

while (x < 1 || x > 100)

{

/* If the entered number is out of the given range then repeats the loop */

cout << "That number is out of range.\n";

cout << "Enter a number in the range 1 – 100 : ";

//Get the value from the user

cin >> x;

}

}

Algorithm:

Algorithm to implement a function with reference call is as follows:

  • Start the program...

Blurred answer
Students have asked these similar questions
1. Level the resources (R) for the following network. Show exactly which activity is being moved at each cycle and how many days it is being moved. Show all cycles required to utilize the free float and the back float. B H 3 3 L 2 0-0-0 A C F G K N P Q T 0 3 2 2 1 2-2-2 7R 8R 4R 6R 4R 2R 5R 4R D 1 2R 2 M 000 4R 2 4R 1 2 3 4 B5 B BE B 5 5 7 D 2003 C NO C MBSCM В H 5 2 F 7 7 8 SH2F80 5 Н Н 6 7 7L3G4+ 6H2G4 J 4 4 14 8 L K 00 36 9 10 11 12 13 14 15 P 2 Z+ N N 4 4 Z t 2334 4 Σ + M M 4 +
2. Perform resource allocation for the following project. Resource limits are 6 labors and 2 helpers. Legend: Activity Dur Resources G H 2 3 2L 1H 2L OH A 1 3L 1H + B D F J K 3 4 6 2 4 4L 2H 3L OH 4L 1H 2L 2H 4L 2H C E 2 2 I 1 2L 1H 3L 1H 5L 1H
Need Java method please. Thank you.

Chapter 6 Solutions

Starting Out with C++: Early Objects (9th Edition)

Chapter 6.9, Problem 6.11CPChapter 6.9, Problem 6.12CPChapter 6.9, Problem 6.13CPChapter 6.9, Problem 6.14CPChapter 6.9, Problem 6.15CPChapter 6.11, Problem 6.16CPChapter 6.11, Problem 6.17CPChapter 6.11, Problem 6.18CPChapter 6.13, Problem 6.19CPChapter 6.13, Problem 6.20CPChapter 6.13, Problem 6.21CPChapter 6.13, Problem 6.22CPChapter 6.13, Problem 6.23CPChapter 6.15, Problem 6.24CPChapter 6.15, Problem 6.25CPChapter 6.15, Problem 6.26CPChapter 6, Problem 1RQEChapter 6, Problem 2RQEChapter 6, Problem 3RQEChapter 6, Problem 4RQEChapter 6, Problem 5RQEChapter 6, Problem 6RQEChapter 6, Problem 7RQEChapter 6, Problem 8RQEChapter 6, Problem 9RQEChapter 6, Problem 10RQEChapter 6, Problem 11RQEChapter 6, Problem 12RQEChapter 6, Problem 13RQEChapter 6, Problem 14RQEChapter 6, Problem 15RQEChapter 6, Problem 16RQEChapter 6, Problem 17RQEChapter 6, Problem 18RQEChapter 6, Problem 19RQEChapter 6, Problem 20RQEChapter 6, Problem 21RQEChapter 6, Problem 22RQEChapter 6, Problem 23RQEChapter 6, Problem 24RQEChapter 6, Problem 25RQEChapter 6, Problem 26RQEChapter 6, Problem 27RQEChapter 6, Problem 28RQEChapter 6, Problem 29RQEChapter 6, Problem 30RQEChapter 6, Problem 31RQEChapter 6, Problem 32RQEChapter 6, Problem 33RQEChapter 6, Problem 34RQEChapter 6, Problem 35RQEChapter 6, Problem 36RQEChapter 6, Problem 37RQEChapter 6, Problem 38RQEChapter 6, Problem 39RQEChapter 6, Problem 1PCChapter 6, Problem 2PCChapter 6, Problem 3PCChapter 6, Problem 4PCChapter 6, Problem 5PCChapter 6, Problem 6PCChapter 6, Problem 7PCChapter 6, Problem 8PCChapter 6, Problem 9PCChapter 6, Problem 10PCChapter 6, Problem 11PCChapter 6, Problem 12PCChapter 6, Problem 13PCChapter 6, Problem 14PCChapter 6, Problem 15PCChapter 6, Problem 16PCChapter 6, Problem 17PCChapter 6, Problem 18PCChapter 6, Problem 19PCChapter 6, Problem 20PC
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
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
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:9781337569798
Author:ECKERT
Publisher:CENGAGE L
.2: Function Parameters and Arguments - p5.js Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=zkc417YapfE;License: Standard Youtube License