COSC TEST Chapter 6 Practice

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

A function's formal parameter list cannot be empty.

False

A value-returning function can return two values via the return statement.

False

A value-returning function returns only floating-point values

False

If the formal parameter list of a function is empty, the parentheses after the function name are not needed.

False

The execution of a return statement in a user-defined function terminates the program.

False

The following return statement returns the value 10. return 10, 16;

False

The function heading int funcAlpha(float u, char v, int g) in a C++ program will cause a syntax error because the function return type is int and so the first parameter, u, must be of type int.

False

The function main is always compiled first, regardless of where in the program the function main is placed.

False

The output of the statement cout << toupper('8') << endl; is undefined since there is no upper case letter corresponding to '8'.

False

The return statement return x + 1; first returns the value of x and then increments the value of x

False

To use a predefined value-returning function in a program, the programmer only needs to know the appropriate header file, the name of the function, and the type of the value returned by the function

False

To use the predefined function abs, the program must include the header file ctype

False

When writing a function prototype, you do not have to specify the data type of each parameter.

False

The heading of the function is also called the ____.

Function Header

Given the following function: int strange(int x, int y) { if (x > y) return x + y; else return 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

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

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>

A variable or expression listed in a call to a function is called the ____.

Actual Parameter

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.00);

Which of the following function prototypes is valid?

int funcExp(intx, floatv);

Which statement below about prototypes and headers is true?

prototypes end with a semicolon but headers do not

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

void

A function definition consists of the function heading and the body of the function

True

A function prototype ends with a semicolon.

True

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

True

In C++, a function prototype is the function heading without the body of the function

True

It is not necessary to specify the names of formal parameters in a function prototype.

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.

True

The execution of a C++ program always begins with the function main.

True

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

True

The statement return static_cast<char>(x + 5); where x is an int variable, returns a char value in a value-returning function.

True

To use a predefined function, the program must include the appropriate header file.

True

To use the predefined function exp, the program must include the header file cmath.

True

Using functions greatly enhances the program's readability because it reduces the complexity of the function main.

True

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

actual ; formal


Kaugnay na mga set ng pag-aaral

Nursing Fundamentals NUR 120D Exam 1

View Set

SAT Practice 1 - October 11, 2023 Reading and Writing: Question 1

View Set

CH 10 Queue, Ch 11 Queue Implementation, CH 6 - Stack Implementation, CH 5 Stacks, CH 3 - Bag implementation that links data, CH 2 Bag implementations that use Arrays, CH 1 - Bags,

View Set