Ch.3 Flashcards
Which boolean operation is described by the following table?
A B Operation
True True True
True False True
False True True
False False False
or
Which of the following data types may be used in a switch statement?
A) long
B) char
C) enum
D) int
E) all of the above
all of the above
What is the value of the following expression?
(true && (4/3 || !(6)))
true
When testing a program with a loop, which of the following tests should be done?
A) one less than the maximum number of iterations
B) no iterations of the loops
C) the maximum number of iterations
D) one more than the maximum number of iterations
E) A, B, and C
one less than the maximum number of iterations
no iterations of the loops
the maximum number of iterations
Which of the following is not a good reason for choosing a certain loop control?
A) What the loop does
B) If the loop is in a function
C) The condition for ending the loop
D) The minimum number of iterations of the loop
If the loop is in a function
Which of the following data types can be used in a switch controlling expression?
A) char
B) enum
C) float
D) int
E) A, B, and D
char
enum
int
Which boolean operation is described by the following table?
A B Operation
True True True
True False False
False True False
False False False
and
Given the following enumerated data type definition, what is the value of SAT?
enum myType{SUN=3,MON=1,TUE=3,WED,THUR,FRI,SAT,NumDays};
7
What is the output of the following code fragment?
int i = 5;
switch(i)
{
case 0:i = 15;break;
case 1:i = 25;break;
case 2:i = 35;break;
case 3:i = 40;
default:i = 0;
}
0
If you want a loop to quit iterating if x < 10 and y > 3, what would be the proper loop condition test?
(x >= 10 || y <= 3)
Given the following enumerated data type definition, what is the value of SAT?
enum myType{SUN,MON,TUE,WED,THUR,FRI,SAT,NumDays};
6
What is the value of x after the following code executes?
int x = 10;
if( ++ x > 10)
{
x = 13;
}
13
What is the value of x after the following code executes?
int x = 10;
if(x ++ > 10)
{
x = 13;
}
11
Which of the following are equivalent to (!(x < 15 && y >= 3))?
(x >= 15 || y < 3)
If you need to write a do-while loop that will ask the user to enter a number between 2 and 5 inclusive, and will keep asking until the user enters a correct number, what is the loop condition?
(2 > number || number > 5)