rip test 3 ch 5 & 6

Ace your homework & exams now with Quizwiz!

In a sentinel-controlled while loop, the body of the loop continues to execute until the EOF symbol is read.

false

In the for statement, if the loop condition is omitted, it is assumed to be false.

false

It is possible that the body of a while loop may not execute at all, but the body of a for loop executes at least once.

false

Loop control variables are automatically initialized in a loop.

false

The body of a do...while loop may not execute at all.

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 following while loop terminates when j > 20. j = 0; while (j < 20)

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

The statement in the body of a while loop acts as a decision maker.

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

A(n) ____-controlled while loop uses a bool variable to control the loop.

flag

After a break statement executes, the program continues to execute with the first statement after the structure.

true

An infinite loop may execute indefinitely.

true

Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5. n = 1; while (n < 5) { n++; cout << n << " "; }

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

Both while and for loops are pre-test loops.

true

If a continue statement is placed in a do...while structure, the loop-continue test is evaluated immediately after the continue statement.

true

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

true

In a counter-controlled while loop, the loop control variable must be initialized before the loop.

true

In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.

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 control statements in the for loop include the initial statement, loop condition, and update statement.

true

The control variable in a flag-controlled while loop is a bool variable.

true

The do...while loop has an exit condition but no entry condition.

true

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

true

The execution of a break statement in a while loop terminates the loop.

true

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

true

The fourth number in a Fibonacci sequence is found by taking the sum of the previous two numbers in the sequence.

true

The function eof returns true if the program has read past the end of the input file

true

The number of iterations of a counter-controlled loop is known in advance.

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

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

void

Suppose sum, num, and j are int variables, and the input is 4 7 12 9 -1. What is the output of the following code? cin >> sum; cin >> num; for (j = 1; j <= 3; j++) { cin >> num; sum = sum + num; } cout << sum << endl;

2.24 1.25

What is the output of the following C++ code? count = 1; num = 25; while (count < 25) { num = num - 1; count++; } cout << count << " " << num << endl;

251

What is the next Fibonacci number in the following sequence? 1, 1, 2, 3, 5, 8, 13, 21, ...

34

What is the value of x after the following statements execute? int x = 5; int y = 30; do x = x * 2; while (x < y);

40

The ____ statement can be used to eliminate the use of certain bool variables in a loop.

break

A sentinel-controlled while loop is an event-controlled while loop whose termination depends on a special value.

true

A function's formal parameter list cannot be empty.

false

A syntax error will result if the control statements of a for loop are omitted.

false

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

false

A value-returning function returns only floating-point values

false

An EOF-controlled while loop is another name for a sentinel-controlled while loop.

false

Assume all variables are properly declared. The following for loop executes 20 times. for (i = 0; i <= 20; i++) cout << i;

false

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

false

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

What is the output of the following C++ code? num = 10; while (num > 10) num = num - 2; cout << num << endl;

10

What is the output of the following C++ code? int j; for (j = 10; j <= 10; j++) cout << j << " "; cout << j << endl;

11 11

Suppose sum and num are int variables, and the input is 18 25 61 6 -1. What is the output of the following code? sum = 0; cin >> num; while (num != -1) { sum = sum + num; cin >> num; } cout << sum << endl;

110

Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output of the code? sum = 0; cin >> num; for (int j = 1; j <= 4; j++) { sum = sum + num; cin >> num; } cout << sum << endl;

125

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

14

Assume all variables are properly declared. What is the output of the following C++ code? num = 100; while (num <= 150) num = num + 5; cout << num << endl;

155

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>

Which of the following loops does not have an entry condition?

A Do While Loop

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

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

actual parameter

Consider the following code. int limit; int counter = 0; cin >> limit; while (counter < limit) { cin >> entry; triple = entry * 3; cout << triple; counter++; } cout << endl; This code is an example of a(n) ____ while loop.

counter controlled

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

____ loops are called post-test loops.

do - while

Which of the following is a repetition structure in C++?

do while

Which of the following loops is guaranteed to execute at least once?

do while loop

A break statement is legal in a while loop, but not in a for loop.

false

When a continue statement is executed in a ____, the update statement always executes.

for loop

The heading of the function is also called the ____.

function header

A loop that continues to execute endlessly is called a(n) ____ loop.

infinite

Which of the following function prototypes is valid?

int funcExp(intx, floatv);

What executes immediately after a continue statement in a while and do-while loop?

loop continue test

In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s).

looping

A loop is a control structure that allows you to repeat a set of statements until certain conditions are met.

true

Which statement below about prototypes and headers is true?

prototypes end with a semicolon but headers do not

*Which executes first in a do...while loop?

the statement

What is the output of the following loop? count = 5; cout << 'St'; do { cout << 'o'; count--; } while (count <= 5);

this is an infinite loop

A do...while loop is a post-test loop.

true

A for loop is typically called an indexed for loop.

true

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

true

A function prototype ends with a semicolon.

true


Related study sets

That Was Then, This is Now: Chapter Questions

View Set

ARRT SONOGRAPHY PHYSICS REVIEW!!

View Set

CISSP Domain 7: Security Operations

View Set