QUIZ 2 Flashcards
int limit;
int reps =0;
cin»limit;
while (reps <limit)
{
cin»_space; entry;
triple = entry*3;
cout «_space;triple;
reps++;
}
cout«endl;
This code is an example of a(n) ________ while loop.
counter-controlled
Putting in front of a logical expression reverses the value of that logical expression
!
Which of the following will causes a logical error if you are attempting to compare x to 5?
if (x==5)
if(x=5)
if(x>=5)
if(x<=5)
if(x=5)
Suppose sum and num are int variables, the input is 18 25 61 6 -1. What is the output of the following code?
Sum =0
Cin» num;
While (num != -1)
{
Sum = sum + num;
Cin»num;
}
Cout«sum«endl;
110
Assume you have three int variable: x =2 , y=6, and z. Choose the value of z in the following expression: z(y/x>0) ? x:y;
2
What is the output of the following C++ code?
Int x =55;
Int y = 5;
Switch (x%7)
{
Case 0;
Case 1;
Y++;
Case 2:
Case 3:
Y=y+2;
Case 5:
Case 6:
Y=y-3;
}
Cout«y«endl;
2
What is the output of the following C++ code?
num=10;
while (num>10)
num=num-2;
cout «_space;num «_space;endl;
10
Consider the following code.
Int limit
Int reps =0;
Cin»_space; limit
While (reps < limit)
{
Cin»entry;
Triple=entry*3;
Cout«triple;
Cout«triple;
Reps++;
}
Cout«endl;
This code is an example of a(n) _________ while loop.
Counter-controlled
In C++, the operators != and == have the same order of precedence.
True
Suppose x and is 5 and y is 7. Choose the value of the following expression:
(x != 7) && (x <= y)
True
When one control statement is located within another, it is said to be
nested
Which of the following statements generates a random number between 0 and 50?
srand(time(0));
num = rand() % 50;
A(n) ______-controlled while loop uses a bool variable to control the loop.
flag
Which of the following is a repetition structure in C++?
while…do
if
switch
do…while
do…while
A loop that continues to execute endlessly is called a(n) _______ loop.
infinite