CSCI Test Chapter 4

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

True

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

False

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

False

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

conditional

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

||

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

True

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

True

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

||

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

&&

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

integer constant

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

integer

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

True, False

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 __________.

Braces

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

When the flag is set to false it indicates the condition does not yet exist. When the flag is set to true it indicates that the condition does exist.

How does a flag work?

&&

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

The trailing else provides code that is executed when none of the conditions in the if/else if statement are true.

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

True

The if statement regards an expression with a nonzero value as __________.

False

The if statement regards an expression with the value 0 as __________.

nested

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

left-to-right

The logical operators have __________ associativity.

default

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

False, True

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

True, False

A relational expression is either __________ or __________.

block

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

Flag

A Boolean variable signaling that some condition exists in the program.

break

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

Relational

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

It takes two expressions as operands and creates a single expression that is true only when both subexpressions are true.

Briefly describe how the && operator works.

It takes two expressions as operands and creates a single expression that is true when either of the subexpressions are true.

Briefly describe how the || operator works.

Yes. The if statement can test any value that yields a Boolean value (true or false) or a numeric value. When testing a numeric expression, a nonzero numeric value is considered true, and the value 0 is considered false.

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

if/else if Statement

In this statement, the conditions are tested until one is found to be true. The conditionally executed statement(s) are executed and the program exits the statement.

Series Of if Statements

Statements which execute and test their conditions because they are not connected.

True

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

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 It's safe to assume that all uninitialized variables automatically start with 0 as their value.

False

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

True

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

False

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

False

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

!

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

Because they test for specific relationships between items. The relationships are greater-than, less-than, equal-to, greater-than or equal-to, less-than or equal-to, and not equal-to.

Why are the relational operators called relational?

It visually sets the conditionally-executed statements apart from the surrounding code. This is so you can easily identify the code that is conditionally-executed.

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

strings (C-strings, specifically)

You use the __________ operator to determine whether one string object is greater then another string object.


संबंधित स्टडी सेट्स

Saunders reproductive system review

View Set

Ch 47 Gastric and Duodenal Disorders

View Set

Missouri Laws and Rules Pertinent to Insurance

View Set

MCQs in ELECTRICITY AND MAGNETISM

View Set

COM1000 everything everywhere, Public Speaking Chapter 8, COMM chps 1,2,4,6,10, Public Speaking Chapter 10

View Set

Intro to Biology Chapter 3 questions

View Set