Week 3 Flashcards

1
Q

Data type for logical high and low data values (i.e., true or false)?

A

Bool

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

Value 0 evaluates as which Boolean value?

A

False

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

Value of anything other than zero evaluates as which Boolean value?

A

True

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

Order in which statements are executed in a program is referred to as?

A

The flow of control

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

The ordinary flow of control is?

A

Sequential

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

A statement used to alter the ordinarily sequential flow of control?

A

Control structure

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

An expression used by a control structure to determine the flow of control?

A

Branching condition

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

Control structure used to change flow of control between different alternatives?

A

Selection or branching

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

A statement of data values compored using logical operators is known as?

A

Logical expression, or assertion

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

Characteristics of the bool data type?

A

It holds only true or false, which are constants, and reserved words

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

Operators used to compare values in relational expressions are known as?

A

Relational operators

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

Relational operator == checks for?

A

Equality between to values

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

Relational operator != checks for?

A

Inequality between two values

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

Relational operator > checks for?

A

Greater than relationship

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

Relational operator < checks for?

A

Less than relationship

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

Relational operator => checks for?

A

Greater than or equal to

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

Relational operator =< checks for?

A

Less than or equal to

18
Q

Chars are logically compared in what way?

A

Alphabetically, according to ASCII

19
Q

Mixed type relational expressions are not always safe because?

A

Of implicit type coercion by the compiler

20
Q

Bools compared with numerical data types evaluate as?

21
Q

When comparing strings, one of them must be?

A

An identified string object as opposed to a literal C string

22
Q

When comparing nonidentical strings, which string is considered less than the other?

A

The string where the first nonidentical character in both strings comes earlier in the ASCII table, or whichever is smaller if they match to the end of one of the strings

23
Q

The fundamental control structure in C++ is?

A

The if statement

24
Q

If statements evaluate a relational expression how?

A

If true else if false

25
What common algorithm uses if else statements?
Input validatiob
26
If a branching condition contains no relational operators, what is the behaviour?
Evaluates true if result not zero or null
27
If an if block contains another if block, how’s this referred?
Nested if
28
Nested ifs can be formatted…?
if else if else if … else
29
Logical operator && refers to?
AND operation
30
Logical operator || refers to?
OR operation
31
Logical operator ! refers to?
NOT operation, or inverse
32
If statements should only lead into else if clauses if?
The conditions are interdependent, or mutually exclusive
33
The final else is in an if else statement is called?
Dangling else
34
The dangling else is connected to which statement?
The most recent if statement that doesn’t have a connected else statement
35
What kind of evaluation methodology does C++ use for logical expressions?
Short-circuit evaluation
36
What is short circuit evaluation?
Evaluation in left to right order, which short circuits as soon as the compiler calculates the Boolean value for the entire expression
37
Which mathematical operation equates to the AND operator in Boolean algebra?
Multiplication
38
Which mathematical operation equates to the OR operation in Boolean algebra?
Addition
39
Which mathematical operation relates to the NOT operation in Boolean algebra?
Unary subtraction
40
Where do relational operators, the assignment operator and logical operators come in the order of precedence?
1. Unary, *, %, / 2. > < => =< 3. == != 4. && 5. || 6. ! 7. =
41
Why is it not appropriate to check equality between floating point numbers?
Because tiny inaccuracies (due to the calculation and storage methods of real numbers) mean that rarely are two floating point numbers the same
42
How is it better to check for float equivalence?
std::fabs(a-b) > 0.00001 Where fabs (floating point absolute value) function returns difference