CIS 13 - Computer Information System » Spring 2020 » Quiz 1

Need help with your exam preparation?

Question #1
Which of the following if statement compares the value of the int variable Age, and based on the value of age prints to the monitor: “Enjoy Retirement” for age range 65 to 125, “Keep Working” for Age range 25 to 65, “Get an Education” for Age range of 0 to 25, otherwise “Not a Valid Age”. Assume all variables are declared and initialized. Check as many as you like.
A.   if ( age > 65 ) cout <<"Enjoy Retirement" ; else if (age > 25 ) cout << "Keep Working" ; else if (age >0 ) cout <<"Get an education"; else cout << "Not a valid age";
B.   if ( age > 65 && age <= 125 ) cout <<"Enjoy Retirement" ; if (age > 25 && age <= 65) cout << "Keep Working" ; if (age >0 && age <= 25) cout <<"Get an education"; if (age <= 0 ) cout << "Not a valid age";
C.   if ( age > 65 && age <= 125 ) cout <<"Enjoy Retirement" ; else if (age > 25 ) cout << "Keep Working" ; else if (age >0 ) cout <<"Get an education"; else cout << "Not a valid age";
D.   if ( age > 65 && age <= 125 ) cout <<"Enjoy Retirement" ; else if (age > 25 && age <= 65) cout << "Keep Working" ; else if (age >0 && age <= 25) cout <<"Get an education"; else cout << "Not a valid age";
E.   None of the given answers is correct
Question #2
In C++, key words are written in all lowercase letters.
A.   FALSE
B.   TRUE
Question #3
What will the following code display? int x = 23, y = 34, z = 45; cout << x << y << z << endl;
A.   233445
B.   23 34 45
C.   xyz
D.   23 34 45
Question #4
The following statement will output $5.00 to the screen: cout << setprecision(5) << dollars << endl;
A.   FALSE
B.   TRUE
Question #5
Which of the following will allow the user to input the values 15 and 20 and have them stored in variables named base and height, respectively?
A.   cin >> base >> height;
B.   cin >> base >> height >> endl;
C.   cin>> base , height;
D.   None of these
E.   cin << base << height;
Question #6
What will be displayed after the following statements execute? int num1 = 5; int num2 = 3; cout << "The result is " << (num1 * num2 + 10.0) << endl;
A.   The result is (num1 * num2 + 10)
B.   The result is 5 * 3 + 10
C.   The result is 25
D.   None of these
E.   The result is 65
Question #7
The default section is required in a switch statement.
A.   FALSE
B.   TRUE
Question #8
The following code correctly determines whether x contains a value in the range of 0 through 100, inclusive. if (x > 0 && <= 100)
A.   TRUE
B.   FALSE
Question #9
Which value can be entered to cause the following code segment to display the message "That number is acceptable"? int number; cin » number; if (number > 10 && number < 100) cout « “That number is acceptable.\n”; else cout « “That number is not acceptable. \n”;
A.   100
B.   99
C.   0
D.   10
E.   all of these
Question #10
What is printed? int x =3, y =4; float w, a = 2.5; w = x / y * a ; w = x / y * a ; a += x * y ; x = y % x ; cout << w << “ “ << a << “ “ << x << “ “ << y << endl ;
A.   0 14.5 1 4
B.   0.000 14.500 1 4
C.   0.0 14.50 1 4
D.   None of the given answers are correct
Question #11
What does the following code fragment write to the monitor? int sum = 14; if ( sum < 20 ) cout << "Under " ; else{ cout << "Over " ; cout << "the limit." ; }
A.   Over the limit.
B.   Under the limit.
C.   None of the given answers are correct
D.   Under
E.   Over
Question #12
What does the following code fragment write to the monitor? int sum = 7; if ( sum > 20 ) cout << "You win " ; else cout<< "You lose " ; cout << "the prize.";
A.   None of the given answers are correct
B.   You win the prize.
C.   You win
D.   You lose the prize.
E.   You lose

Need help with your exam preparation?