You are on page 1of 1

Quiz # 1

Select the best answer (5. Marks).


1. What's wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6);
a. the question mark should be an equal sign
b. the first semicolon should be a colon
c. there are too many variables in the statement
d. the conditional operator is only used with a strings
2.

Which looping process checks the test condition at the end of the loop?

a.
b.
c.
d.

for
while
do-while
no looping process checks the test condition at the end

3.
a.
b.
c.
d.

What's wrong? for (int k = 2, k <=12, k++)


the increment should always be ++k
the variable must always be the letter i when using a for loop
there should be a semicolon at the end of the statement
the commas should be semicolons

4.

The statement i++; is equivalent to


i = i + i;
i = i + 1;
i = i - 1;
i --;

a.
b.
c.
d.

5. Which looping process is best used when the number of iterations is known?
a. for
b. while
c. do-while
d. all looping processes require that the iterations be known
Prompt a user to enter N numbers and stop when enters 0, and then fined all even
numbers. (5 Marks).

You might also like