ET 221 - Chapter 3

¡Supera tus tareas y exámenes ahora con Quizwiz!

If x = 3, which of the following sets x to 7? (a) x *= 4; (b) x += 4; (c) x =+ 4; (d) x + 4 = x;

(b) x += 4;

In which of the following is y not equal to 5 after execution? Assume that x is equal to 4. (a) y = 5; (b) y = x++; (c) y = ++x; (d) y = x = 5;

(b) y = x++;

If grade has the value of 60 what will the following code print? if (grade >= 60) { puts("Passed"); } (a) nothing (b) 60 (c) Passed (d) puts("Passed");

(c) Passed

Which assignment expression is equivalent to c = c / 2 ? (a) c / = 2 (b) c / c = 2 (c) c /= 2 (d) c =/ 2

(c) c /= 2

The two key attributes of an algorithm are:

Actions and order of actions

Indentation in the if selection statement is ________.

Always optional

Having a loop within a loop is known as

Nesting

An uninitialized variable contains

The value last stored in the memory location reserved for that variable

What do psuedocode programs do?

They help the programmer "think out" a program

Various C statements enable you to specify that the next statement to be executed may be other than the next one in sequence. This is called __________.

Transfer of control

Which of the following statements is true? (a) A counter variable that stores only non-negative numbers should be declared as an unsigned integral type. (b) A counter variables that stores only non-negative numbers should be declared as a signed integral type. (c) The type of a counter does not matter (d) None of the above.

(a) A counter variable that stores only non-negative numbers should be declared as an unsigned integral type.

Which of the following will not increment variable c by one? (a) c + 1; (b) c++; (c) ++c; (d) c += 1;

(a) c + 1;

The diamond flowcharting symbol is also called the __________ symbol.

Decision

Counter-controlled iteration is often called __________ iteration because the number of iterations is known before the loop begins executing.

Definite

Pseudocode does not typically include:

Definitions

In a flowchart of an algorithm, what is the shape of the decision symbol?

Diamond

Flowchart symbols are connected by arrows called __________.

Flowlines

The conditional operator (?:) ________.

is the only ternary operator in C

Which of the following statements is true about undefined behavior, which can leave a system open to attack? (a) It's not possible to have undefined behavior when adding two integers. (b) Adding two integers can result in arithmetic overflow, which can cause undefined behavior. (c) You should not worry about undefined behavior in your programs. (d) None of the above.

(b) Adding two integers can result in arithmetic overflow, which can cause undefined behavior.

Which of the following will generate an error? (a) if (answer == 7) { puts("correct"); } else { puts("incorrect"); } (b) puts(answer == 7 ? "correct" : "incorrect"); (c) printf("%s\n", answer == 7 ? "correct" : "incorrect"); (d) answer == 7 ? puts("correct") : puts("incorrect");

(b) puts(answer == 7 ? "correct" : "incorrect");

Which of the following encompasses the other three? (a) sequence structure (b) iteration structure (c) control structure (d) selection structure

(c) control structure

Which of the following is an iteration statement? (a) if (b) if...else (c) do...while (d) switch

(c) do...while

A correct decision symbol has __________ flowlines emerging from it.

2

How many types of control statements exist in C?

3

Any C program we'll ever need to build can be constructed from only __________ different control statements combined in only __________ ways.

7, 2

A fatal logic error is always caused by:

An attempt to divide by zero

Small circle symbols in a flowchart are often called __________ symbols.

Connector

A statement is called a block if it ________.

Is a compound statement that contains definitions

Placing a semicolon after the parenthesized condition in an if statement leads to a __________ error in single-selection if statements and a __________ error in double-selection if statements.

Logic, syntax

Specifying the order in which statements are to be executed in a computer program is called:

Program control

The __________ flowchart symbol is also called the action symbol.

Rectangle

Bohm and Jacopini's work demonstrated that all programs could be written in terms of only three control statements, namely sequence, __________ and iteration.

Selection

Indefinite iteration is controlled by a

Sentinel value

Normally, statements in a program are executed one after the other in the order in which they are written. This is called __________ execution.

Sequential

In indefinite iteration, an input value

Should always be evaluated before being processed

The __________ is called a multiple selection statement.

Switch

The __________ selection statement performs one of many different actions, depending on the value of an expression.

Switch

The C compiler ignores __________ characters like blanks, tabs and newlines used for indentation and vertical spacing

Whitespace

Which statement is true? a) Each of C's control statements is characterized as being single-entry, single-exit. b) Each of C's control statements is characterized as being single-entry, multiple-exit. c) Each of C's control statements is characterized as being multiple-entry, single-exit. d) Each of C's control statements is characterized as being multiple-entry, multiple-exit.

a) Each of C's control statements is characterized as being single-entry, single-exit.

Which statement is true about the contents of a correct diamond symbol in a correct flowchart. a) It must contain an expression that evaluates to zero or one. b) It must contain a condition or expression that can be either true or false. c) It must contain relational operators. d) It must contain equality operators.

b) It must contain a condition or expression that can be either true or false.

Which statement is false? a) A compound statement can be placed anywhere in a program that a single statement can be placed. b) The if selection statement can have only one statement in its body. c) A set of statements contained within a pair of braces ({ and }) is called a compound statement. d) An if slection statement can have a compound statement in its body.

b) The if selection statement can have only one statement in its body.

Which statement is true? a) Unless directed otherwise, the computer automatically executes C statements one before the other. b) The sequence structure is essentially built into C. c) A flowchart is a pseudocode representation of an algorithm or a portion of an algorithm. d) Like pseudocode, flowcharts are useful for developing and representing algorithms, although flowcharts are preferred by most programmers.

b) The sequence structure is essentially built into C.

Which statement is false? a) Pseudocode helps you "think out" a program before attempting to write it in a programming language such as C. b) Pseudocode programs consist purely of characters so programmers may conveniently type pseudocode programs into a computer using an editor program. c) A carefully prepared pseudocode program is only a beginning; it still takes a tremendous amount of work to convert a pseudocode program into a C program. d) Pseudocode consists only of action statements.

c) A carefully prepared pseudocode program is only a beginning; it still takes a tremendous amount of work to convert a pseudocode program into a C program.

Which statement is false? a) Pseudocode is an artificial and informal language that helps you develop algorithms. b) Pseudocode is similar to everyday English. c) Pseudocode is an actual programming language. d) Pseudocode programs are not actually executed on computers.

c) Pseudocode is an actual programming language.

Which of the following is not a synonym for "sentinel value." a) signal value b) dummy value c) counter value d) flag value

c) counter value

Which of the following statements correctly prints "Passed" if the student's grade is greater than or equal to 60 and "Failed" if the student's grade is less than 60? [The quotes, of course, should not print.] a) printf("%s\n", grade >= 60 : "Passed" : "Failed"); b) grade >= 60 : puts("Passed ") ? puts("Failed "); c) printf("%s\n", grade >= 60 ? "Passed" : "Failed"); d) grade >= 60 ? puts("Passed ") ? puts("Failed ");

c) printf("%s\n", grade >= 60 ? "Passed" : "Failed");

Which statement is true? a) With nested control statements, the inner control statement is executed in sequence after the outer control statement completes its own execution. b) With nested control statements, the inner control statement is executed exactly once. c) Experience has shown that the most difficult part of solving a problem on a computer is converting an already correct algoithm to a C program. d) A double-selection statement can be nested in an iteration statement.

d) A double-selection statement can be nested in an iteration statement.

Which statement is true? a) The expression ++(a + 1) adds 2 to a. b) The expression **a multiplies a by 1. c) The ANSI standard for the C programming language specifies the order in which each operator's operands will be evaluated. d) The expression --(abc * 37) is a syntax error

d) The expression --(abc * 37) is a syntax error

Which is not a C iteration statement? a) while b) do...while c) for d) do...for

d) do...for

The __________ is called a single-selection statement.

if

The __________ selection statement performs an action if a condition is true and skips that action if the condition is false.

if

The __________ is called a double selection statement.

if...else

The __________ selection statement performs an action if a condition is true and performs a different action if the condition is false.

if...else

The empty statement is represented by placing __________ where a statement would normally be

semicolon


Conjuntos de estudio relacionados

Combo of ALL (6 of 7) with EMT- Ch 17 Endocrine and Hematologic Emergencies (Orange Book) and 27 others

View Set

Business plan Entrepreneurship Bamford Chapter 3

View Set

ACCTG 431 Ch. 7 - Internal Controls

View Set

CH 12 DNA Replication & Manipulation

View Set