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.   None of the given answers is correct
B.   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";
C.   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";
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.   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";
Question #2
In C++, key words are written in all lowercase letters.
A.   TRUE
B.   FALSE
Question #3
What will the following code display? int x = 23, y = 34, z = 45; cout << x << y << z << endl;
A.   xyz
B.   23 34 45
C.   233445
D.   23 34 45
Question #4
The following statement will output $5.00 to the screen: cout << setprecision(5) << dollars << endl;
A.   TRUE
B.   FALSE
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.   None of these
C.   cin >> base >> height;
D.   cin>> base , height;
E.   cin >> base >> height >> endl;
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 25
C.   The result is 65
D.   None of these
E.   The result is 5 * 3 + 10
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.   FALSE
B.   TRUE
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.   all of these
B.   100
C.   0
D.   99
E.   10
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.0 14.50 1 4
B.   0.000 14.500 1 4
C.   0 14.5 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.   Over
C.   Under
D.   Under the limit.
E.   None of the given answers are correct
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.   You lose
B.   You lose the prize.
C.   None of the given answers are correct
D.   You win the prize.
E.   You win

Need help with your exam preparation?