• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/76

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

76 Cards in this Set

  • Front
  • Back

Describe the difference between the if/else if statement and a series of its statements.

In an if/else if statement, what is the purpose of a trailing else?

What is a flag and how does it work?

Can an if statement test expressions other than relational expressions? Explain.

Briefly describe how the && operator works.

Briefly describe how the || operator works.



Why are the relational operators called relational?

Why do most programmers indent the conditionally executed statements in a decision structure?

An expression using the greater-than, less-than, greater-than-or-equal-to, less-than-or-equal-to, or not-equal to operator is called a(n) ____________ expression.

Relational

A relational expression is either ___________ or __________.

True, false

The value of a relational expression is 0 if the expression is ___________ or 1 if the expression is ___________.

False, true

For an if statement to conditionally execute a group of statements, the statements must be enclosed in a set of ___________.

Braces

In an if/else statement, the if part executes its statement or block if the expression is ___________, and the else part executes its statement or block if the expression is ___________.

True, false

The trailing else in an if/else if statement has a similar purpose as the ___________ section of a switch statement.

Default

The if/else if statement is actually a form of the ___________ if statement.

Nested

If the sub-expression on the left of the ___________ logical operator is false, the right expression is not checked.

&&

If the sub-expression on the left of the ___________ logical operator is true, the right expression is not checked.

||

The ___________ logical operator has higher precedence than the other logical operators.

!

The logical operators have a ___________ associativity.

Left/right

The ___________ logical operator works best when testing a number to determine if it is within a range.

&&

The ___________ logical operator works best when testing a number to determine if it is outside a range.

||

A variable with ___________ scope is only visible when the program is executing in the block containing the variable's definition.

Block

You use the ___________ operator to determine whether one string object is greater than another string object.

>

An expression using the conditional operator is called a(n) ___________ expression.

Conditional

The expression that is tested by a switch statement must have a(n) ___________ value.

Integer or char

The expression following case statement must be a(n) ___________.

Integer or char

A program will "fall through" a case section if it is missing the ___________ statement.

Break

What value will be stored in the variable t after each of the following statements executes?


A) t=(12>1)


B) t=(2<0)


C) t=(5==3*2)


D) t=(5==5)

A) 1


B) 0


C) 0


D) 1

T/F The = operator and the == operator perform the same operation when used in a Boolean expression.

False

T/F A variable defined in an inner block may not have the same name as a variable defined in the outer block.

False

T/F A conditionally executed statement should be indented one level from the if statement.

True

T/F All lines in a block should be indented one level.

True

T/F It's safe to assume that all uninitialized variables automatically start with 0 as their value.

False

T/F When an if statement is nested in the if part of another statement, as in an if/else if, the only time the inner is executed is when the expression of the outer is true.

False

T/F The scope of a variable is limited to the block in which is is defined.

True

T/F You can use the relational operators to compare string objects.

True

T/F x!=y is the same as (x>y||x<y)

True

T/F y<x is the same as x>=y

False

T/F x>=y is the same as (x>y&&x=y)

False

To ___________ a value means to increase it by one, and to ___________ a value means to decrease it by one.

Increment, decrement

When the increment or decrement operator is placed before the operant (or to the operand's left), the operator is being used in ___________ mode.

Prefix

When the increment or decrement operator is placed after the operand (or to the operand's right), the operator is being used in ___________ mode.

Postfix

The statement or block that is repeated is known as the ___________ of the loop.

Body

Each repetition of a loop is known as a(n)___________.

Iteration

A loop that evaluates its test expression before each repetition is a(n) ___________ loop.

Pretest

A loop that evaluates its test expression after each repetition is a(n) ___________ loop.

Posttest

A loop that does not have a way of stopping is a(n) ___________ loop.

Infinite/endless

A(n) ___________ is a variable that counts the number of times a loop repeats.

Counter

A(n) ___________ is a sum of numbers that accumulates with each iteration of a loop.

Running total

A(n) ___________ is a variable that is initialized to some starting value, usually zero, and then has numbers added to it in each iteration of a loop.

Accumulator

A(n) ___________ is a special value that marks the end of a series of values.

Sentinal

The ___________ loop always iterates at least once.

Do-while

The ___________ and ___________ loops will not iterate at all if their test expressions are false to start with.

While, for

The ___________ loop is ideal for situations that require a counter.

For

Inside the for loop's parentheses, the first expression is the ___________, the second expression is the ___________, and the third expression is the ___________.

Initialization, test, update

A loop that is inside another is called a(n) ___________ loop.

Nested

The ___________ statement causes a loop to terminate immediately.

Break

The ___________ statement causes a loop to skip the remaining statements in the current iteration.

Continue

T/F The operand of the increment and decrement operators can be any valid mathematical expression.

False

T/F The cout statement in the following program segment will display 5:


intx=5;


cout<<x++;

True

T/F The cout statement in the following program segment will display 5:


int x=5;


cout<<++x;

False

T/F The while loop is a pretest loop.

True

The do-while loop is a pretest loop.

False

The for loop is a posttest loop

False

T/F It is not necessary to initialize counter variables.

False

T/F All three of the for loop's expressions may be omitted.

True

T/F One limitation of the for loop is that only one variable may be initialized in the initialization expression.

False

T/F Variables may be defined inside the body of a loop.

True

T/F A variable may be defined in the initialization expression of the for loop.

True

T/F In a nested loop, the outer loop executes faster than the inner loop.

False

T/F In a nested loop, the inner loop goes through all of its iterations for every single iteration of the outer loop.

True

T/F To calculate the total number of iterations of a nested loop, add the number of iterations of all the loops.

False

T/F The break statement causes a loop to stop the current iteration and begin the next one.

False

T/F The continue statement causes a terminated loop to resume.

False

T/F In a nested loop, the break statement only interrupts the loop it is placed in.

True

T/F When you call an ofstream object's open member function, the specified file will be erased if it already exists.

False