CSCI study Guide Test 2

studied byStudied by 64 people
5.0(1)
get a hint
hint

A control structure aleters the normal sequential flow of execution in a program

1 / 58

Tags and Description

59 Terms

1

A control structure aleters the normal sequential flow of execution in a program

True

New cards
2

Conditional statements help incorporate decision making into programs

True

New cards
3

In C++, both ! and != are relational operators.

False

New cards
4

In C++, both "!", "&&" and "||" are relational operators.

False

New cards
5
The expression (x >= 0 && x

False

New cards
6

The value of the expression 'a' < 'A' is true.

False

New cards
7

In C++, all relational operators are evaluated before logical operators.

False

New cards
8

. If a semicolon is placed after the expression in an if...else statement, the else statement is always executed.

False

New cards
9

The expression in the following if statement evaluates to true only if the value of score is 50. if (score = 50) grade = 'Z';

False

New cards
10

In a switch statement, every case must have a break.

False

New cards
11

The following while loop terminates when j > 20.

j = 0; while (j < 20) j++;

False

New cards
12

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

True

New cards
13

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

True

New cards
14

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

False

New cards
15

Loop control variables are automatically initialized in a loop.

False

New cards
16

In an EOF-controlled loop if the program reads any faulty data (such as a char value into an int variable), the input stream variable returns the value false.

True

New cards
17

The control statements in the for loop include the initial statement, loop condition, and update statement.

True

New cards
18

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

True

New cards
19

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

False

New cards
20

Both while and for loops are pretest loops

True

New cards
21

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

True

New cards
22

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

True

New cards
23

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

New cards
24

A value-returning function return only floating point values

False

New cards
25

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

New cards
26
The statement return static_cast(x + 5); where “x” is an int variable, returns a char value in a valuereturning function

True

New cards
27

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

False

New cards
28

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

False

New cards
29

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

False

New cards
30

In a ____ control structure, the computer executes particular statements depending on some condition(s).

Selection

New cards
31

Which of the following is a relational operator?

==

New cards
32

Suppose that “x” is an int variable. Which of the following expressions always evaluates to true?

(x > 0) || (x <== 0)

New cards
33

Which of the following operators has the highest precedence

!

New cards
34

Which of the following expressions correctly determines that “x” is greater than 10 and less than 20

10 < x && x < 20

New cards
35

What is the output of the following C++ code? int x = 35; int y = 45; int z; if (x > y) z = x + y; else z = y – x; cout << x << " " << y << " " << z << endl;

35 45 10

New cards
36

When one control statement is located within another, it is said to be ____.

Nested

New cards
37

Which of the following will cause a logical error if you are attempting to compare “x” to 5

if(x=5)

New cards
38

What is the output of the following code? char lastInitial = 'S'; switch (lastInitial) { case 'A': cout << "section 1" <<endl; break; case 'B': cout << "section 2" <<endl; break; case 'C': cout << "section 3" <<endl; break; case 'D': cout << "section 4" <<endl; break; default: cout << "section 5" <<endl;

Section 5

New cards
39

What is the output of the following C++ code? int x = 55; int y = 5; switch (x % 7) { case 0: case 1: y++; case 2: case 3: y = y + 2; case 4: break; case 5: case 6: y = y – 3; } cout << y << endl;

2

New cards
40

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

10

New cards
41

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

New cards
42

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

New cards
43

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

Flag

New cards
44

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

infinite

New cards
45

Which of the following is the initial statement in the following for loop? (Assume that all variables are properly declared.) int i; for (i = 1; i < 20; i++) cout << "Hello World"; cout << "!" << endl

i = 1;

New cards
46

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

10 11

New cards
47

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

The statement

New cards
48

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

New cards
49

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

do...while loop

New cards
50

To use the predefined function “tolower”, the program must include the header file

cctype

New cards
51

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

8.0

New cards
52

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

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

New cards
53

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

New cards
54

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

New cards
55

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

New cards
56

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

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

New cards
57

Which of the following function prototypes is valid

int funcExp(int x, float v);

New cards
58

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

cout << myFunc(myFunc(7, 8), 15);

New cards
59

The statement: return 8, 10; returns the value

10

New cards

Explore top notes

note Note
studied byStudied by 218 people
Updated ... ago
4.8 Stars(6)
note Note
studied byStudied by 2 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 25 people
Updated ... ago
4.5 Stars(2)
note Note
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 13 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 17 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 22 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 24 people
Updated ... ago
5.0 Stars(1)

Explore top flashcards

flashcards Flashcard39 terms
studied byStudied by 49 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard47 terms
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard145 terms
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard49 terms
studied byStudied by 13 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard51 terms
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard31 terms
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard51 terms
studied byStudied by 2 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard25 terms
studied byStudied by 28 people
Updated ... ago
5.0 Stars(1)