TBD

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

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

> (relational)

What is a flag and how does it work?

A flag is a Boolean variable signaling that some condition exists in the program. When the flag is set to false it indicates the conditions does not yet exist. When the flag is set to true it indicates that the condition does exist.

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

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

Curly braces.

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

In an if/else if statement, the conditions are tested until one is found to be true. The conditionally executed statement(s) are executed and the program exits the if/else if statement. In a series of if statements, all of the if statements execute and test their conditions because they are not connected.

Briefly describe how the && operator works.

It takes two expressions as operands and creates a single expression that is either true or false depending on the operands here are the results.

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 call a(n) _______ expression.

Relational Operator

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

The is/else if statement is used to verify a sequence of situations. If a code has several conditional expressions with if/else if statement, the code verifies the first conditions and executes that block only if the first condition is true. If the first condition is false, it verifies the next conditions and executes that block only if the first condition is true, and so on. At the end of the if/else if statement, the code has an else block without conditional expression, it is called as trailing else. The block of statements under this trailing else is executed when all the preceding conditional expressions are false.

Briefly describe how the || operator works.

The || operator takes two expressions as operands and creates an expression that is true when either of sub expressions are true.

Why are the relational operators called relational?

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.

A relational expression is either ____ or ____.

True or 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 _____.

True, False.

The if statement regards an expression with a nonzero as _______.

True.

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

Yes. An if statement can test expression other than relational expressions. The if statement test the expression that returns the numeric value or Boolean value; that is True (or 1) of False (or 0). In the if statement, if the value of the expression inside the parentheses is true, then the statements in the if-block are executed. If the value of the expression inside the parentheses is false, then the statements in the else-block are executed.

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

break

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

conditional

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

default

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

false.

Using the following chart, write an if/else if statement that assigns .10, .15, or .20 to commission, depending on the value in sales. Sales Commission Rate up to $10,000 10% $10,000 to $15,000 15% over $15,000 20%

if(sales <= 10000) commission = 0.10; else if (sales > 10000 && sales <15000) commission = 0.15; else commission = 0.20;

Write an if statement that assigns 100 to x when y is equal to 0.

if(y == 0) x = 100;

Write an if/else statement that assigns 0 to x when y is equal to 10. Otherwise it should assign 1 to x.

if(y == 10); x = 0; else x = 1;

The expression following a case statement must be a _____ _____.

integer literal or constant.

The expression that is test by a switch statement must have a ____ value.

integral type

The logical operators have _______ associativity.

left-right

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

local

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

nested

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

| |

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

| |

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

• The conditionally executed statements are placed in decision structure because they need to execute based on the condition evaluation either executes true or false block. • In a decision structure a specific action is taken only based on the condition. If it is true then specific task is performed otherwise some other alternative task is performed. •The condition statements are indented because they need to execute under condition and easy to understanding and easy to finding error if any.

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

!

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

&&

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

False or true.

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

&&


Ensembles d'études connexes

MGMT 361 Midterm 1 Practice questions, MGMT 361 Exam 1

View Set

Chapter 15 assessing the head and neck

View Set

R&W CLASSIFICATION AND EXEMPLIFICATION

View Set