Originally Posted by
Techstudent
Complete this coding to print exactly 3 numbers on every line:
for (int k = 5; k < 65; k++)
if ( ________________ == 1)
System.out.println (" " + k);
else
System.out.print (" " + k);
Why is the answer k%3?
Do you know what is the % operator?
Originally Posted by
Techstudent
In the following problem:
if (x == 5 || y > 2) is fully equivalent to if ( ! ( ________________ ) )
Why is the answer x != 5 && y <= 2
Do you know De Morgan's laws? (hint: search on Wikipedia)
This is inherent to boolean algebra.
Originally Posted by
Techstudent
In the following problem:
Complete this if-statement (you may use else) to assign to x the smaller of y and z:
if (y < z) ________________ ;
Why is the answer x = y; else x = z
If y is lower than z, what is the smaller? And otherwise?