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?

A

0 and 1

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
Q

What common algorithm uses if else statements?

A

Input validatiob

26
Q

If a branching condition contains no relational operators, what is the behaviour?

A

Evaluates true if result not zero or null

27
Q

If an if block contains another if block, how’s this referred?

A

Nested if

28
Q

Nested ifs can be formatted…?

A

if
else if
else if

else

29
Q

Logical operator && refers to?

A

AND operation

30
Q

Logical operator || refers to?

A

OR operation

31
Q

Logical operator ! refers to?

A

NOT operation, or inverse

32
Q

If statements should only lead into else if clauses if?

A

The conditions are interdependent, or mutually exclusive

33
Q

The final else is in an if else statement is called?

A

Dangling else

34
Q

The dangling else is connected to which statement?

A

The most recent if statement that doesn’t have a connected else statement

35
Q

What kind of evaluation methodology does C++ use for logical expressions?

A

Short-circuit evaluation

36
Q

What is short circuit evaluation?

A

Evaluation in left to right order, which short circuits as soon as the compiler calculates the Boolean value for the entire expression

37
Q

Which mathematical operation equates to the AND operator in Boolean algebra?

A

Multiplication

38
Q

Which mathematical operation equates to the OR operation in Boolean algebra?

A

Addition

39
Q

Which mathematical operation relates to the NOT operation in Boolean algebra?

A

Unary subtraction

40
Q

Where do relational operators, the assignment operator and logical operators come in the order of precedence?

A
  1. Unary, *, %, /
  2. > < => =<
  3. == !=
  4. &&
  5. ||
  6. !
  7. =
41
Q

Why is it not appropriate to check equality between floating point numbers?

A

Because tiny inaccuracies (due to the calculation and storage methods of real numbers) mean that rarely are two floating point numbers the same

42
Q

How is it better to check for float equivalence?

A

std::fabs(a-b) > 0.00001
Where fabs (floating point absolute value) function returns difference