Conditions
Loops
Selection Statements
Definitions
Miscellaneous
100

What must the condition be to execute the statement? What happens if the condition is false?

TRUE. It skips the statement.

100

When does a for loop end?

When a false is encountered in the loop.

100

Both the if and the else get a condition to execute. True or False?

False, the else doesn't get a condition.

100

What is a sentinel value?

A specific value that will stop your loop.

100

What is short-circuiting? 

Once a true is found, immediately goes to statement.

200

What does 'if (x != sum)' mean?

x does not equal sum.

200

What is the order (steps 1-4) of the for loop?

1. initialization

2. condition

3. body

4. increment

200

What does the nested if statement print?

int value = 6

if (value >= 0)

    if (value%2 = 0)

        s.o.p ("Dog");

    else 

        s.o.p ("Cat");

Dog

200

If the condition of the loop never becomes false and the loop goes on forever, what is it called?

An infinite loop.

200

What is the increment and decrement operator?

The increment operator adds 1 to the value (++) and the decrement operator subtracts 1 from the value (--).

300

What is the '&&' operator and what does it do? What about '||'? And what about '!'?

&& is the AND operator and means that everything in the condition must be true. || is the OR operator and means that only one part of the condition must to be true. ! is the NOT operator and means the value does not equal something.

300

What is the difference between a for loop and a while loop?

For loop: If we know how many times we want to execute the loop (count control).

While loop: When we don't know how many times we'll go through the loop.

300

What are the relational operators?

== equal to

!= not equal to

< less than

<= less than or equal to

> greater than

>= greater than or equal to


300

Is the code correct? If not, find the errors and fix them.

int x = 10

while (x>5)

    s.o.p (x/0)

No. Cannot divide by 0.

int x = 10

while (x>5)

    s.o.p (x/2); //or change output overall


400

Rewrite this condition.

if !(x=3 || !(x>5 && x<=0))

if (x!=3 && (x<=5 || x>0))



400

What does this code do?

int x=1

while (x<5)

{    s.o.p (x);

      x--;

}


Prints x and subtracts 1 until x equals 4.

500

Create a for loop that print odd numbers from 1 to 99.

for (int x=1; x<100; x+2) OR 

for (int x=1; x<=99; x+2)

    s.o.p (x);