COSC 1436 Ch. 6

Ace your homework & exams now with Quizwiz!

If the formal parameter list of a function is empty, the parentheses after the function name are not needed. (T/F)

False

The execution of a return statement in a user-defined function terminates the program. (T/F)

False

The following return statement returns the value 10. return 10, 16; (T/F)

False

The function main is always compiled first, regardless of where in the program the function main is placed. (T/F)

False

Which of the following statement about function prototypes and function headers is true?

Function prototypes end with a semicolon, but function headers do not.

The output of the statement: ​ cout << tolower('$') << endl; ​ is ____.

'$'

Given the following function: int strange(int x, int y){if (x > y)return x + y;elsereturn x - y; } what is the output of the following statement?cout << strange(4, 5) << endl;

-1

The statement: return 8, 10; returns the value ____.

10

The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is ____.

14.0

The statement: return 2 * 3 + 1, 1 + 5; returns the value ____

6

The statement: return 37, y, 2 * 3; returns the value ____

6

What value is returned by the following return statement? int x = 5;return x + 1;

6

Given the following function: int next(int x){return (x + 1);}what is the output of the following statement?cout << next(next(5)) << endl;

7

The output of the statement: ​ cout << pow(2.0, pow(3.0, 1.0)) << endl; ​ is ____.

8.0

Assume the following. static_cast<int>('a') = 97 static_cast<int>('A') = 65 ​ The output of the statement: ​ cout << static_cast<int>(tolower('B')) << endl; is ____.

98

To use the predefined function tolower, the program must include the header file ____.

<cctype>

The standard header file for the abs(x)function is ____.

<cmath>

Given the function prototype: ​ float test(int, int, int); ​ which of the following statements is legal?

cout << test(7, 14, 23);

Given the function prototype: ​ double testAlpha(int u, char v, double t); ​ which of the following statements is legal?

cout << testAlpha(5, 'A', 2);

Given the following function prototype: ​ double tryMe(double, double); ​ which of the following statements is valid? Assume that all variables are properly declared.

cout << tryMe(2.0, 3.0);

A variable listed in a function header is known as a(n) ____ parameter.

formal

The heading of a function is also called a ____.

function header

Which of the following function prototypes is valid?

int funcTest(int, int, float);

Given the following function prototype: ​ int test(float, char); ​ which of the following statements is valid?

int u = test(5.0, '*');

When you attach & after the dataType in the formal parameter list of a function, the variable following that dataType becomes a(n) ____________________ parameter.

reference

The ____________________ of a function consists of the function name and its formal parameter list.

signature

A function ____________________ is a function that is not fully coded.

stub

Functions that do not have a return type are called ____ functions.

void

If a function needs to return more than one value, as a rule of good programming style, you should change it to a(n) ____________________ function and use the appropriate reference parameters to return the values.

void

____________________ parameters are useful in three situations: When the value of the actual parameter needs to be changed • When you want to return more than one value from a function • When passing the address would save memory space and time relative to copying a large amount of data

Reference

Assume that all variables are properly declared. The following statement in a value-returning function is legal. if (x % 2 == 0)return x;elsereturn x + 1; (T/F)

True

In C++, a function prototype is the function heading without the body of the function. (T/F)

True

Once you write and properly debug a function, you can use it in the program (or different programs) again and again without having to rewrite the same code repeatedly. (T/F)

True

The data type of a variable in a return statement must match the function type. (T/F)

True

The following function heading in a C++ program is valid: int funcExp(int u, char v, float g) (T/F)

True

Using functions greatly enhances a program's readability because it reduces the complexity of the function main. (T/F)

True

A function prototype is ____.

a declaration, but not a definition

A variable or expression listed in a call to a function is called a(n) ____.

actual parameter


Related study sets

Shoulder/Arm Group #3 (Rhomboid Major and minor, levator scapula, serratus anterior, pec major and minor, subclavius)

View Set

Social Context and Human Biology

View Set

Securities Industry Essentials (SIE)

View Set

Integumentary System Adaptive Quizzing

View Set

AP Euro Midterm (Chapters 16-17) - Short Answer

View Set

Human Development Chapter 6 Study Guide

View Set

Reconstruction carpet bag & scalawag vocabulary

View Set