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
The __ carries out all arithmetic and logical operations.
ALU
26
True or False: All registers proved temporary storage.
True
27
True or False: All software is written in programming languages.
True
28
True or False: The screen (such as a touch screen) and keyboard are examples of input devices.
True
29
True or False: The ALU performs arithmetic operations and finds logical errors.
False
30
True or False: Analog signals represent information with a sequence of 0s and 1s.
False
31
True of False: When you compole your program, the compiler not only identifies the logic errors, but also typically suggests how to correct them.
False
32
True or False: Examples of output devices are the mouse and secondary storage.
False
33
True or False: Assembly, C, C++, and Java are all high-level languages.
False
34
True or False: The CPU contains several components, including the CU and ALU.
True
35
True or False: Programming is a process of problem solving.
True
36
True or False: In assembly language, an instruction is an easy to remember form called a mnemonic.
True
37
An __ is 1,024 bytes.
kilobyte
38
How do you convert a seven bit binary representation of an ASCII character to an eight bit binary representation?
Add zeros in the front so that there is 8 characters
39
The Finch Robot could be considered an example of an input device, output device, or both?
both
40
An __ is 1,024 gigabytes.
terabyte
41
How many digits are used when writing numbers in base 6?
6
42
True or False: The include statement belongs before using namespace std;.
True
43
Suppose count = 1. After the statement count ++ executes, the value of count is __.
2
44
True or False: A reserved word can be used as an identifier name.
False
45
True or False: Suppose that count is an int cariable. The statements --coutn; and count--; both decrement the value of count by 2.
False
46
True or False: The conversion of a value from one data type to another is called type casting.
True
47
True or False: The value '*' belongs to the char data type.
True
48
True or False: An identifier can be ANY sequence fo digits, letters, and the underscore character.
False
49
True or False: If a C++ arithmetic expression has no parentheses, operators are evaluated from left to right following the order of operations.
True
50
True or False: Suppose a = 4. After the execution of statement b = a++; b is 4 and a is 5.
False
51
True or False: A C++ program si processed by the preprocessor before being processed by the compiler.
True
52
True or False: The value fo a variable cannot change during program execution.
False
53
True or False: Suppose a = 5. After the execution of the statement ++a; the value of a is 6.
True
54
True or False: Multiplication and division have the same operator precedence
True
55
True or False: Suppose that count is an int variable. The statements ++count and ++count both increment the value of count by 1.
True
56
True or False: The following is a legal C++ identifier: Hello!
False
57
True or False: All prepprocessor commands start with the symbol #.
True
58
True or False: Every C++ program must have a function called main.
True
59
True or False: In C++, reserved words are the same as predefined identifiers.
False
60
True or False: Suppose x = 8. After the execution of the statement y = x++; y is 9 and x is 8.
False
61
%
modulus operator
62
--
decrement operator
63
=
assignment operator
64
>>
stream extraction
65
stream insertion
66
++
increment operator
67
When one control statement is located within another, it is said to be __.
nested
68
What determines that x is greater than 10 and less than 20?
10
69
In a __ control structure, the computer executes particular statements depending on some conditions.
selection
70
``` Which of the following operators has the lowest precedence? | | ! = && ```
=
71
A(n) ... statement causes an immediate exit from the switch structure.
break
72
True or False: If you are comparing x to 5, ( x = 5 ) will cause a logical error.
True
73
``` Which of the following is a relational operator? ! &;&; == = ```
==
74
The appearance of = in place of == resembles a __.
silent killer
75
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.
defaults
76
The expression in an if statement is sometimes called a(n) ___.
selection statement
77
``` Which of the following operators has the highest precedence? * = ! % ```
!
78
What is the not equal to operator?
!=
79
When a switch expression evaluates to a logical value, the __ label is not reachable.
default
80
A ternary operator takes __ arguments.
3
81
T or F: Every if statement must have a corresponding else
F
82
T or F: The operators != and == have the same order of precedence.
T
83
T or F: The value of the expression 'a'
F
84
T or F: Conditional statements help incorporate decision making into programs
T
85
T or F: The value of the expression 7 + 8
T
86
T or F: A control structure alters the normal sequential flow of execution in a program
T
87
T or F: In C++, all relational operators are evaluated before logical operators.
T
88
In C++, && has a higher precedence than l l
True
89
Including a semicolon before the action statement in a one way selection causes a syntax error
False
90
In C++, !, &&, and l l are called relational operators.
False
91
The symbol > is a logical operator.
True
92
If a semicolon is placed after the expression in and if...else statement, the else statement is always executed
False
93
With short circuit evaluation, the computer evaluates the logical expression from left to right
True
94
Suppose x = 10 and y = 20. The value of the expression ((x >= 10) && (y
True
95
In C++, both ! and != are relational operators
False
96
In C++, >> is called the stream insertion operator
False
97
A program uses repetition to implement a branch
False
98
In C++, the logical operator and is &&
True
99
A compound statement or block of statements is treated as a single statement.
True
100
Suppose found = true and num = 6. The value of the expression (!found) l l (num > 6) is false
True
101
In a switch statement, every case must have a break
False
102
Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q is true.
True