Problem 1
Mark the following statements as true or false. a. \(A\) function that changes the value of a reference parameter also changes the value of the actual parameter. b. \(A\) variable name cannot be passed to a value parameter. c. If a \(C++\) function does not use parameters, parentheses around the empty parameter list are still required. d. In \(C++,\) the names of the corresponding formal and actual parameters must be the same. e. Whenever the value of a reference parameter changes, the value of the actual parameter changes. f. In \(C++,\) function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function. g. Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided. h. In a program, global constants are as dangerous as global variables. i. The memory for a static variable remains allocated between function calls.
Problem 2
Identify the following items in the programming code shown below.
a. Function prototype, function heading, function body, and function
definitions
b. Function call statements, formal parameters, and actual parameters
c. Value parameters and reference parameters
d. Local variables and global variables
#include
Problem 3
a. Explain the difference between an actual and a formal parameter. b. Explain the difference between a value and a reference parameter. c. Explain the difference between a local and a global variable.
Problem 4
include
Problem 5
Write the definition of a void function that takes as input a decimal number and as output 3 times the value of the decimal number. Format your output to two decimal places.
Problem 6
Write the definition of a void function that takes as input two decimal numbers. If the first number is nonzero, it outputs second number divided by the first number; otherwise, it outputs a message indicating that the second number cannot be divided by the first number because the first number is 0
Problem 7
Write the definition of a void function with three reference parameters of type int, double, and string. The function sets the values of the int and double variables to 0 and the value of the string variable to the empty string.
Problem 8
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.
Problem 9
include
Problem 10
include