Concept explainers
Consider the following statements:
Which of the following statements are valid? If they are invalid, explain why. (4)
volume = box (length, width, height);
volume = box (length, 3.8, height);
cout << box(num1, num3, num2) << endl;
cout << box (length, width, 7.0)<< endl;
volume = box (length, num1, height);
cout <<box(6.2, height) << endl;
volume = box (length + width, height)
volume = box (num1, num2 + num3) ;
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
EBK MINDTAPV2.0 FOR MALIK'S C++ PROGRAM
- 17. A function should determine the average of x and y. What should be the function's parameters and return value(s)? A.Parameters: none Return values: X,y B.Parameters: ×, y, average Return value: none C.Parameters: average Return values; X, y D.Parameters: X, y Return value: averagearrow_forwardWhy do you need to include function prototypes in a program that contains user-defined functions? (5)arrow_forwardMark the following statements as true or false: a. To use a predefined function in a program, you need to know only the name of the function and how to use it. (1) b. A value-returning function returns only one value. (2, 3) c. Parameters allow you to use different values each time the function is called. (2, 7, 9) d. When a return statement executes in a user-defined function, the function immediately exits. (3, 4) e. A value-returning function returns only integer values. (4) f. A variable name cannot be passed to a value parameter. (3, 6) g. If a C++ function does not use parameters, parentheses around the empty parameter list are still required. (2, 3, 6) h. In C + + , the names of the corresponding formal and actual parameters must be the same. (3, 4, 6) i. A function that changes the value of a reference parameter also changes the value of the actual parameter. (7) j. Whenever the value of a reference parameter changes, the value of the actual parameter changes. (7) k. In C++, function definitions can be nested; that is, the definition of one function can be enclosed in the body of another function. (9) l. Using global variables in a program is a better programming style than using local variables, because extra variables can be avoided. (10) m. In a program, global constants are as dangerous as global variables. (10) n. The memory for a static variable remains allocated between function calls. (11)arrow_forward
- Which statement of the following is the most appropriate? Group of answer choices One good method for specifying what a function is supposed to do is to provide a precondition and postcondition for the function. One good method for specifying what a function is supposed to do is to provide a precondition and postcondition for the function. These form a contract between the programmer who uses the function and the programmer who writes the function. Using the assert function to check preconditions can significantly reduce debugging time, and the assertion-checking can later be turned off if program speed is a consideration. One good method for specifying what a function is supposed to do is to provide a precondition and postcondition for the function. These form a contract between the programmer who uses the function and the programmer who writes the function. Using the assert function to check preconditions can significantly reduce debugging time, and the…arrow_forwardNeed help with all answerarrow_forwardWhy would you use a formal parameter to get data into a function when you could use a symbolic constant instead? Explain.arrow_forward
- Answer all questions. I will rate your answer. Thank youarrow_forwardPROGRAMMING LANGUAGE: C++ Note: Kindly refer to the attached screenshot for the sample program. 1. Identify the format of the function used: no return type & no parameter, with return type & no parameter, no return type & with parameter and with return type & with parameter. 2. Identify the format and actual parameters. 3. Identify the function signature 4. Identify parameter if value parameter, reference parameter or constant reference parameter is used. 5. Identify the the scope of variable used. 6. Identify the type of C++ function is used.arrow_forwardPROGRAMMING LANGUAGE: C++ Note: Kindly refer to the attached screenshot for the sample program. 1. Identify the format of the function used: no return type & no parameter, with return type & no parameter, no return type & with parameter and with return type & with parameter. 2. Identify the format and actual parameters. 3. Identify the function signature 4. Identify parameter if value parameter, reference parameter or constant reference parameter is used. 5. Identify the the scope of variable used. 6. Identify the type of C++ function is used.arrow_forward
- PROGRAMMING LANGUAGE: C++ Note: Kindly refer to the attached screenshot for the sample program. 1. Identify the format of the function used: no return type & no parameter, with return type & no parameter, no return type & with parameter and with return type & with parameter. 2. Identify the format and actual parameters. 3. Identify the function signature 4. Identify parameter if value parameter, reference parameter or constant reference parameter is used. 5. Identify the the scope of variable used. 6. Identify the type of C++ function is used.arrow_forwardPROGRAMMING LANGUAGE: C++ Note: Kindly refer to the attached screenshot for the sample program. 1. Identify the format of the function used: no return type & no parameter, with return type & no parameter, no return type & with parameter and with return type & with parameter. 2. Identify the format and actual parameters. 3. Identify the function signature 4. Identify parameter if value parameter, reference parameter or constant reference parameter is used. 5. Identify the the scope of variable used. 6. Identify the type of C++ function is used.arrow_forwardPROGRAMMING LANGUAGE: C++ Note: Kindly refer to the attached screenshot for the sample program. 1. Identify the format of the function used: no return type & no parameter, with return type & no parameter, no return type & with parameter and with return type & with parameter. 2. Identify the format and actual parameters. 3. Identify the function signature 4. Identify parameter if value parameter, reference parameter or constant reference parameter is used. 5. Identify the the scope of variable used. 6. Identify the type of C++ function is used.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning