Which of the following is an input device for a computer?
a. CPU
b. Monitor
c. Mouse
d. Printer
e. Memory - Answer -c
Which of the following is a correct way to print out "Hello World!" on the screen and the
cursor
goes to the new line after the printing finished.
a. cout >> "Hello, World!\n" ;
b. cout << "Hello, World!/n" ;
c. cout >> "Hello, World!" << endl ;
d. cout << "Hello, World!" << endl; - Answer -d
Which of the following is correct?
a. #include < iostream>
b. #include <iostream>
c. #include <iostream >
d. All of a, b, and c
*pg. 26 - Answer -b
What will be the output of the following code? Assume that originally int type variable x
=6
if(x % 3 == 0)
cout << x << " is a multiple of 3 " << endl;
else
cout << x << " is not a multiple of 3 " << endl;
a. 6 is a multiple of 3
b. 6 is not a multiple of 3
c. x is a multiple of 3
d. x is not a multiple of 3
e. There is a syntax error - Answer -a
How many numbers will the following code print out?
Assume int x = 6; before the loop.
do {
cout << x << endl;
x--;
} while (x > 6);
a. one
, b. six
c. zero
d. infinite
e. There is a syntax error - Answer -a
Which of the following declares a constant variable named TAX_RATE with type double
and
initialize it to 0.085?
a. constant double x = 0.085.
b. const double x = 0.085.
c. const double x = 0.085;
d. constant double x = 0.085;
pg. 97 - Answer -c
What is the value of sum after the execution of the following loop?
int sum = 0;
int n = 5;
while(n > 0) {
sum += n;
n = n - 1;
}
a. 15
b. 14
c. infinite
d. There is a syntax error. - Answer -a
Evaluate the following Boolean expression: true || false && true
a. true || false && true = true || (false && true) = true || false = true
b. true || false && true = (true || false) && true = true && true = true
c. false
d. It cannot be determined. You need add parenthesis.
pg. 114 - Answer -a
Suppose int x = 5; what is the output of the following statement?
if( x > 10)
cout << "Hello";
else if (x > 6)
cout << "World";
else
cout << "Hi";
a. Hello
b. World
c. HelloWorld
d. Hi