Procedural Programming midterm review || A+ Guaranteed.
In C++, __________ is the stream insertion operator. correct answers <<
In C++, all preprocessor commands begin with _____. correct answers #
Which of the following arithmetic operators can you use only with the integral data type?
a. *
b. %
c. /
d. + correct answers b. %
A memory location whose content is not allowed to change during program execution is known
as a correct answers const
To force floating-point output to show exactly as many digits after the decimal point as specified
by the precision, use the _________ manipulator. correct answers fixed
The extraction operator takes _____ operands. correct answers 2
To read a string containing blanks, you can use the function correct answers getline
The output stream variables can use the manipulator _________ to fill the unused columns with
a character other than a space. correct answers setfill
Which of the following is not an input stream function?
a. ignore
b. putback
c. get
d. endl correct answers d. endl
The operator ! is ______ , so it only has one operand.
a. relational
b. unary
c. binary
d. ternary correct answers b. unary
To use a parameterized stream manipulator in a C++ program, you must include the header file
_________.
a. fstream
b. iostream
c. iomanip
d. string correct answers c. iomanip
To force floating-point output to show the decimal point and trailing zeros, use the ___________
manipulator.
,a. scientific
b. decimal
c. point
d. showpoint correct answers d. showpoint
In C++, the symbol ==, which consists of two equal signs, is called the _______ operator.
a. equality b. assignment c. comparison
d. relational
e. logical correct answers a. equality
Which of the following expressions evaluates to true?
a. "Hello" > "Hi"
b. "Hello" = "hello"
c. "Air" < "An"
d. "Bill" >= "Billy" correct answers c."Air" < "An"
A ___________ statement causes an immediate exit from the switch structure. correct answers
break
In ________ evaluation, the computer evaluates a logical expression from left to right and stops
as soon as the value of the expression is known.
a. conditional
b. associative
c. decision maker
d. short-circuit correct answers d. short-circuit
When C++ evaluates a logical expression, any nonzero value is treated as _____________.
correct answers true
The specification of the assert function is found in the header file _________. correct answers
cassert
Putting one control structure inside another is called __________. correct answers nesting
If the possible range of values for a multiple selection statement cannot be reduced to a finite set
of values, you must use the ___________ structure.
a. if
b. if ... else
c. switch
d. nested if
e. loop correct answers b. if ... else
What does the following expression evaluate to?
!('A' < 'B') correct answers false
What does the following expression evaluate to?
,(14 >= 5) && ('A' < 'B') correct answers true
What does the following expression evaluate to?
!!(6 <= 7) correct answers true
What does the following expression evaluate to?
(24 >= 35) || ('A' < 'B') correct answers true
The logical expression !(p && !q) equivalent to (!p || q). (Hint: See if they have matching truth
tables.) correct answers true
Suppose that beta is an int variable. Consider the following C++ code.
cin >> beta;
switch (beta % 10)
{
case 0:
case 1:
beta = beta - 2;
break;
case 2:
case 8:
beta += beta;
break;
case 4:
case 7:
beta = static_cast<int>
(pow(beta, 3.0));
case 6:
case 9:
beta = static_cast<int>
(sqrt(beta * 1.0));
break;
default:
beta = -5;
}
If the input is 1, beta is _______ after execution.
If the input is 23, beta is ______ after execution.
If the input is 89, beta is ______ after execution.
If the input is 4, beta is _______ after execution.
If the input is 8, beta is _______after execution.
If the input is 36, beta is ______ after execution correct answers a. -1
b. -5
c. 9
d. 8
e. 16
f. 6
, What does the following expression evaluate to?
(24 >= 35) && ('A' < 'B') correct answers false
The value of the expression in a switch statement must be a(n)
a. string
b. integral
c. floating-point
d. integral or floating-point correct answers b. integral
The equality operator made of up ______ equal sign(s) and the assignment operator is mode up
of _________ equal sign(s) correct answers 2
1
C++ uses short-circuit evaluation for logical expressions. Therefore, the value of x is after the
following poorly-written code is executed.
int x = 5;
int y = 1;
if(y < 1 && x = 2)
{
x++;
}
else if (y > 0 && x = 50)
{
--x;
}
a. 1
b. 2
c. 3
d. 4
e. 5
f. 6
g. 49
h. 50
i. 51 correct answers g. 49
The use of the keywords true and false are considered best to use for logical expressions, over
the equivalent values of 1 and 0. correct answers true
__________ programming divides a problem into subproblems which are then solved by
specifying a series of computational steps to be carried out. correct answers Procedural
In C++, __________ is the stream insertion operator. correct answers <<
In C++, all preprocessor commands begin with _____. correct answers #
Which of the following arithmetic operators can you use only with the integral data type?
a. *
b. %
c. /
d. + correct answers b. %
A memory location whose content is not allowed to change during program execution is known
as a correct answers const
To force floating-point output to show exactly as many digits after the decimal point as specified
by the precision, use the _________ manipulator. correct answers fixed
The extraction operator takes _____ operands. correct answers 2
To read a string containing blanks, you can use the function correct answers getline
The output stream variables can use the manipulator _________ to fill the unused columns with
a character other than a space. correct answers setfill
Which of the following is not an input stream function?
a. ignore
b. putback
c. get
d. endl correct answers d. endl
The operator ! is ______ , so it only has one operand.
a. relational
b. unary
c. binary
d. ternary correct answers b. unary
To use a parameterized stream manipulator in a C++ program, you must include the header file
_________.
a. fstream
b. iostream
c. iomanip
d. string correct answers c. iomanip
To force floating-point output to show the decimal point and trailing zeros, use the ___________
manipulator.
,a. scientific
b. decimal
c. point
d. showpoint correct answers d. showpoint
In C++, the symbol ==, which consists of two equal signs, is called the _______ operator.
a. equality b. assignment c. comparison
d. relational
e. logical correct answers a. equality
Which of the following expressions evaluates to true?
a. "Hello" > "Hi"
b. "Hello" = "hello"
c. "Air" < "An"
d. "Bill" >= "Billy" correct answers c."Air" < "An"
A ___________ statement causes an immediate exit from the switch structure. correct answers
break
In ________ evaluation, the computer evaluates a logical expression from left to right and stops
as soon as the value of the expression is known.
a. conditional
b. associative
c. decision maker
d. short-circuit correct answers d. short-circuit
When C++ evaluates a logical expression, any nonzero value is treated as _____________.
correct answers true
The specification of the assert function is found in the header file _________. correct answers
cassert
Putting one control structure inside another is called __________. correct answers nesting
If the possible range of values for a multiple selection statement cannot be reduced to a finite set
of values, you must use the ___________ structure.
a. if
b. if ... else
c. switch
d. nested if
e. loop correct answers b. if ... else
What does the following expression evaluate to?
!('A' < 'B') correct answers false
What does the following expression evaluate to?
,(14 >= 5) && ('A' < 'B') correct answers true
What does the following expression evaluate to?
!!(6 <= 7) correct answers true
What does the following expression evaluate to?
(24 >= 35) || ('A' < 'B') correct answers true
The logical expression !(p && !q) equivalent to (!p || q). (Hint: See if they have matching truth
tables.) correct answers true
Suppose that beta is an int variable. Consider the following C++ code.
cin >> beta;
switch (beta % 10)
{
case 0:
case 1:
beta = beta - 2;
break;
case 2:
case 8:
beta += beta;
break;
case 4:
case 7:
beta = static_cast<int>
(pow(beta, 3.0));
case 6:
case 9:
beta = static_cast<int>
(sqrt(beta * 1.0));
break;
default:
beta = -5;
}
If the input is 1, beta is _______ after execution.
If the input is 23, beta is ______ after execution.
If the input is 89, beta is ______ after execution.
If the input is 4, beta is _______ after execution.
If the input is 8, beta is _______after execution.
If the input is 36, beta is ______ after execution correct answers a. -1
b. -5
c. 9
d. 8
e. 16
f. 6
, What does the following expression evaluate to?
(24 >= 35) && ('A' < 'B') correct answers false
The value of the expression in a switch statement must be a(n)
a. string
b. integral
c. floating-point
d. integral or floating-point correct answers b. integral
The equality operator made of up ______ equal sign(s) and the assignment operator is mode up
of _________ equal sign(s) correct answers 2
1
C++ uses short-circuit evaluation for logical expressions. Therefore, the value of x is after the
following poorly-written code is executed.
int x = 5;
int y = 1;
if(y < 1 && x = 2)
{
x++;
}
else if (y > 0 && x = 50)
{
--x;
}
a. 1
b. 2
c. 3
d. 4
e. 5
f. 6
g. 49
h. 50
i. 51 correct answers g. 49
The use of the keywords true and false are considered best to use for logical expressions, over
the equivalent values of 1 and 0. correct answers true
__________ programming divides a problem into subproblems which are then solved by
specifying a series of computational steps to be carried out. correct answers Procedural