M02 Flashcards

1
Q

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

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The result of a logial expression cannot be assigned to an int variable, but it can be assigned to a bool variable.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The expression (x >= 0 && x = 100).

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q are true.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In C++, has a higher precedence than l l .

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The operator != and == have the same order of precedence.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A compound statement functions as if it was a single statement.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

if the expression is an assert statement evaluates to true, the program terminates.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

selection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does

A

less than or equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which of the following is a relational operator?

a. =
b. ==
c. !
d.

A

b. ==

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which of the follwing is the “not equal to” relational operator?

a. !
b. l
c. !=
d.

A

c. !=

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Suppose x is 5 and y is 7. Choose the value of the following expression:

(x != 7) && (x

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

a. (x > 0) || ( x = 0) || (x == 0)
c. (x > 0) && ( x 0) && (x == 0)

A

a. (x > 0) || ( x

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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

a. 10

A

c. 10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

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

A

35 45 10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the output of the following code?

if (6 > 8)
{
cout

A

*

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

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

a. if (x = 5)
c. if (x == 5)
d. if (x = 5)

A

d. if (x = 5)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the output of the following code?

char lastInitial = ‘S’;

switch (lastInitial)
{
case ‘A’:
cout

A

section 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

char lastInitial = ‘A’;

switch (lastInitial)
{
case ‘A’:
cout

A

section 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

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

A

2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

You can disable assert statements by using which of the following?

a. #include
b. #define
c. #clear NDEBUG
d. #define NDEBUG

A

d. #define NDEBUG

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

The __ holds the insturctions currently being executed.

A

IR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

The __ carries out all arithmetic and logical operations.

A

ALU

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

True or False: All registers proved temporary storage.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

True or False: All software is written in programming languages.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

True or False: The screen (such as a touch screen) and keyboard are examples of input devices.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

True or False: The ALU performs arithmetic operations and finds logical errors.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

True or False: Analog signals represent information with a sequence of 0s and 1s.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

True of False: When you compole your program, the compiler not only identifies the logic errors, but also typically suggests how to correct them.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

True or False: Examples of output devices are the mouse and secondary storage.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

True or False: Assembly, C, C++, and Java are all high-level languages.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

True or False: The CPU contains several components, including the CU and ALU.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

True or False: Programming is a process of problem solving.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

True or False: In assembly language, an instruction is an easy to remember form called a mnemonic.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

An __ is 1,024 bytes.

A

kilobyte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

How do you convert a seven bit binary representation of an ASCII character to an eight bit binary representation?

A

Add zeros in the front so that there is 8 characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

The Finch Robot could be considered an example of an input device, output device, or both?

A

both

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

An __ is 1,024 gigabytes.

A

terabyte

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

How many digits are used when writing numbers in base 6?

A

6

42
Q

True or False: The include statement belongs before using namespace std;.

A

True

43
Q

Suppose count = 1. After the statement count ++ executes, the value of count is __.

A

2

44
Q

True or False: A reserved word can be used as an identifier name.

A

False

45
Q

True or False: Suppose that count is an int cariable. The statements
–coutn; and count–; both decrement the value of count by 2.

A

False

46
Q

True or False: The conversion of a value from one data type to another is called type casting.

A

True

47
Q

True or False: The value ‘*’ belongs to the char data type.

A

True

48
Q

True or False: An identifier can be ANY sequence fo digits, letters, and the underscore character.

A

False

49
Q

True or False: If a C++ arithmetic expression has no parentheses, operators are evaluated from left to right following the order of operations.

A

True

50
Q

True or False: Suppose a = 4. After the execution of statement b = a++; b is 4 and a is 5.

A

False

51
Q

True or False: A C++ program si processed by the preprocessor before being processed by the compiler.

A

True

52
Q

True or False: The value fo a variable cannot change during program execution.

A

False

53
Q

True or False: Suppose a = 5. After the execution of the statement ++a; the value of a is 6.

A

True

54
Q

True or False: Multiplication and division have the same operator precedence

A

True

55
Q

True or False: Suppose that count is an int variable. The statements ++count and ++count both increment the value of count by 1.

A

True

56
Q

True or False: The following is a legal C++ identifier: Hello!

A

False

57
Q

True or False: All prepprocessor commands start with the symbol #.

A

True

58
Q

True or False: Every C++ program must have a function called main.

A

True

59
Q

True or False: In C++, reserved words are the same as predefined identifiers.

A

False

60
Q

True or False: Suppose x = 8. After the execution of the statement y = x++; y is 9 and x is 8.

A

False

61
Q

%

A

modulus operator

62
Q

A

decrement operator

63
Q

=

A

assignment operator

64
Q

> >

A

stream extraction

65
Q
A

stream insertion

66
Q

++

A

increment operator

67
Q

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

A

nested

68
Q

What determines that x is greater than 10 and less than 20?

A

10

69
Q

In a __ control structure, the computer executes particular statements depending on some conditions.

A

selection

70
Q
Which of the following operators has the lowest precedence?
| |
!
=
&&
A

=

71
Q

A(n) … statement causes an immediate exit from the switch structure.

A

break

72
Q

True or False: If you are comparing x to 5, ( x = 5 ) will cause a logical error.

A

True

73
Q
Which of the following is a relational operator?
!
&;&;
==
=
A

==

74
Q

The appearance of = in place of == resembles a __.

A

silent killer

75
Q

Note that although ___ aren’t required in a switch statement, it’s good practice to include them, even if you think they’ll never be needed.

A

defaults

76
Q

The expression in an if statement is sometimes called a(n) ___.

A

selection statement

77
Q
Which of the following operators has the highest precedence?
*
=
!
%
A

!

78
Q

What is the not equal to operator?

A

!=

79
Q

When a switch expression evaluates to a logical value, the __ label is not reachable.

A

default

80
Q

A ternary operator takes __ arguments.

A

3

81
Q

T or F: Every if statement must have a corresponding else

A

F

82
Q

T or F: The operators != and == have the same order of precedence.

A

T

83
Q

T or F: The value of the expression ‘a’

A

F

84
Q

T or F: Conditional statements help incorporate decision making into programs

A

T

85
Q

T or F: The value of the expression 7 + 8

A

T

86
Q

T or F: A control structure alters the normal sequential flow of execution in a program

A

T

87
Q

T or F: In C++, all relational operators are evaluated before logical operators.

A

T

88
Q

In C++, && has a higher precedence than l l

A

True

89
Q

Including a semicolon before the action statement in a one way selection causes a syntax error

A

False

90
Q

In C++, !, &&, and l l are called relational operators.

A

False

91
Q

The symbol > is a logical operator.

A

True

92
Q

If a semicolon is placed after the expression in and if…else statement, the else statement is always executed

A

False

93
Q

With short circuit evaluation, the computer evaluates the logical expression from left to right

A

True

94
Q

Suppose x = 10 and y = 20. The value of the expression ((x >= 10) && (y

A

True

95
Q

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

A

False

96
Q

In C++,&raquo_space; is called the stream insertion operator

A

False

97
Q

A program uses repetition to implement a branch

A

False

98
Q

In C++, the logical operator and is &&

A

True

99
Q

A compound statement or block of statements is treated as a single statement.

A

True

100
Q

Suppose found = true and num = 6. The value of the expression (!found) l l (num > 6) is false

A

True

101
Q

In a switch statement, every case must have a break

A

False

102
Q

Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q is true.

A

True