Ch 4 - Statement Forms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Control statements fall into two basic classes

A

Conditionals and iteration

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

Relational Operators

A

Are used to compare two values

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

Can you use relational operators to compare Strings

A

No

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

Logical Operators

A

! Logical Not && Logical And || Logical Or

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

Short Circuit Evaluation

A

Style of evaluation which stops as soon as the answer is known

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

Another name for Boolean variables?

A

Flags

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

Test whether done has the value true

A

if(done)

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

?: operator (Question-mark colon operator)

condition ? expression 1 : expression 2

A

Evaluates the condition. If the condition is true expression1 is evaluated. if the condition is falase the value is expression 2.

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

Example of ?: operator

A

max = (x > y) ? x : y;

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

Another example of ?: operator

A

(nItems == 1 ? “ “ : “s”)

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

What is the form of the repeat-N-times pattern

A

for (int i = 0; i < N; i++{
statements etc.
}

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

Initialization

A

setting a variable to its proper starting value

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

Read-until-sentinel pattern

A
while (true) {
    PROMPT USER AND READ IN A VALUE
    if (value == sentintel) break;
    REST OF BODY
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Sentinel

A

a special value used to signal the end of the input list

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

While statement

A

iterative construct which repeatedly execuates a simple statement or block until the conditional expression is false

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

One way to solve the loop and a half program

A

Use the break statement

17
Q

Example of loop and a half

A

while (true){
if ( value == sentintel ) break;
Process the data value
}

18
Q

Operation of the for loop is determined by three expressions

A

init; test; step