Loops
What does the following loop print?
int n = 1;
while (n < 100)
{
n = 2 * n;
System.out.print(n + " ");
} |
2 4 8 16 32 64 128 |
|
What does this code print?
System.out.print("Printing 1 to 10: ");
int i = 1;
while (i >= 10)
{
System.out.print(i + " ");
i++;
} |
Printing 1 to 10: | The loop is never entered! |