Logic and Design Review Questions
Which operator would make the following expression true? False ____ True
OR
How many times will the following loop iterate? Set k = 1 Do Display k Set k = k + 1 Until k > 1
One
What is the first step to use in detecting data type mismatch errors?
Read the input as a string
Examine the following piece of code and determine the data type of the function's return value. Function Real sum ( Integer num1, Integer nume2) Declare Integer result Set result = num1 + num2 Return result End Function
Real
What type of operator can be used to determine whether a specific relationship exists between two values?
Relational
What type of the operators are the following? > < >= <= == !=
Relational
Which structure causes a statement or set of statements to execute repeatedly?
Repetition
What term is used in the ending terminal symbol of a function flowchart?
Return
A loop that accumulates a total as it read each number from a series is often said to keep a what?
Running total
The function _____ specifies the return data type, name of the function, and the parameter variable(s).
Header
The statements that appear between the While and the End While clauses are called the _____.
Body of the loop
A condition is a _____ expression.
Boolean
In addition to using loop to validate data, ____ can also be used to validate data.
Boolean Function
The variable r would contain the value ____ after the execution of the following statement. Declare Integer i = 12 Declare Real r Set r = toReal (i)
12.0
The _____ operator could be used, in some situations, to simplify nested selection structures.
AND
Which operator is best to determine whether x contains a value in the range of 10 through 57?
AND
Which operator would make the following expression false? True ____ False
AND
What two logical operators perform short-circuit evaluation?
AND and OR
Which of the following statements is true after the execution of the following statement? Set needANumber = random(5,10)
All of these (A random number is generation between 5 and 10, The random number is assigned to the variable needANumber, the numbers 5 and 10 are the arguments of the random number function)
Which of the following is a logical operator
All of these (AND, NOT, OR)
Random numbers are commonly used in which type of program?
All of these (Games, Simulations, Statistical analysis, Data encryption)
The term _____ is used to describe any mechanism that accepts input, performs some operation that cannot be seen on the input, and produces output.
Black box
The function _____ comprises one or more statements that are executed when the function is called
Body
What type of loop uses a Boolean expression to control the number of times that it repeats a statement or set of statements?
Condition-controlled
Which function accepts two strings as arguments, returns "True" if the first string contains the second string, and otherwise returns "False"?
Contains
Which structure is a logical design that controls the order in which a set of statements executes?
Control
The following is an example of what type of loop? For k = 7 To maxValue
Count-controlled
To ____ a variable mean to decrease its value
Decrement
The ____ symbol indicates that some condition must be tested in a flowchart.
Diamond
Which loop repeats a statement or set of statements as long as the Boolean expression is false?
Do-Until
Which of these are posttest loops?
Do-While and Do-Until
____ happens when an input operation attempts to read data, but there is no data to read.
Empty input
Which loop is specifically designed to initialize, test, and increment a counter variable?
For
Which loop statement does not contain an increment statement but automatically increments the counter at the end of each iteration?
For
A _____ is a module that returns a value back to the part of the program that called it.
Function
How many times will the following loop iterate? Set k = 1 While k <= 5 Display k End While
Infinite
In the IPO chart, the ____ column describes the data that is passed to the function as arguments.
Input
What is the data type of the value returned by the random library function?
Integer
A case structure is a ____ alternative decision structure.
Multiple
If the expression is false, the _____ operator will return true.
NOT
The ____ operator is a unary operator, as it works with only one operand.
NOT
Which of the following operators reverse the logic of its operand?
NOT
How many times will the following loop iterate? Set k = 1 While k > 5 Display k End While
No iterations
Which operator is used to determine that the operands are not exactly of the same value?
None of these (=, !, =!, ==)
Which of the following is optional when writing a function definition?
None of these (Function header, Function body, Data type, Return statement)
The _____ represents a special value that marks the end of a list of values.
Sentinel
Consider the following statement: A store is giving a discount of 30% for all purchases over $100. Which of the following is not the appropriate structure to used to program the statement?
Sequence
The amount by which the counter variable is incremented in a For loop is known as what?
Step amount
Which function returns a string withing a string?
Substring
In many languages the case structure is called a ____ statement.
Switch
Which of the following statements is true about this Boolean expression? score < 0 AND score > 100
This expression would never be true
How many times will the following loop iterate? For j = 1 To 5 Step 2 Display J End For
Three
In a count-controlled loop, the counter performs ____ action(s).
Three
Which of the following errors occur when a real value is attempted to be assigned to an integer variable?
Type mismatch
Which pair of loops causes a statement or set of statements to repeat as long as a condition is true?
While and Do-While
Which of the following library functions could be used to validate that the correct data type was input for an amount of money?
isReal
The ____ function does the same thing as using the mathematical ^ operator.
pow
Examine the following piece of code and state the return value of the function. Function Real sum ( Integer num1, Integer nume2) Declare Real result Set result = num1 + num2 Return result End Function
result
Which of the following statements is true after the execution of the following statement? y = abs(x)
y contains the absolute value of the value in x