The first statement inside the parenthesis of the for loop. (ie. for( ; ; ))
What is the initial value for the loop variable?
The location of the loop variable initialization:
1
while( 2 ){
3
}
4
What is: 1?
The error(s) in the following code:
for(i = 0; i<20; i++);
System.out.println(i);
What is...
for(int i=0; i<20; i++) ;
System.out.println(i);
The second statement inside the parenthesis of the for loop. (ie. for( ; ; ))
What is the loop condition?
The statement inside of the parenthesis of a while loop. (ie. while( ___ ))
What is the loop condition?
The error(s) in the following code:
While(i<100);
System.out.println(i);
What is...
int i=0;
while(i<100)_;_{
System.out.println(i);
i++;
}
The third statement inside the parenthesis of the for loop. (ie. for( ; ; ))
What is the action step? (or What is the increment/decrement to the loop variable?)
The location of the loop variable action (increment/decrement).
1
while( 2 ){
3
}
4
What is: 3?
The error(s) in the following code:
for(int i=0; i<10; i++)
i+=3;
System.out.println(i);
What is...
for(int i=0; i<10; i++)
{
i+=3;
System.out.println(i);
}___
The output of:
for(int i=1;i<=10;i++)
{
System.out.print(i + " ");
}
What is: "1 2 3 4 5 6 7 8 9 10"?
The output of:
int j = 3;
while ( j <= 11)
{
System.out.print(j + “ ”);
j+=2;
}
What is: "3 5 7 9 11"?
The error(s) in the following code:
int x = keyboard.nextInt();
while(5 < x < 20)
{
System.out.println(x)
x += 5;
}
What is...
int x = keyboard.nextInt();
while(5 < x && x < 20)
{
System.out.println(x);
x+=5;
}
The output for:
int sum = 0;
for(int i = 0; i< 12; i+=2){
sum += i;
}
System.out.print(sum);
What is: 30?
The output of:
int n=0, count=0;
while(n<8) {
count += n;
n+=2;
}
System.out.print( count );
What is: 12?
The error(s) in the following code:
int x = 0;
while(x < 100){
System.out.println(x);
}
What is...
int x= 0;
while(x<100){
System.out.println(x);
i++;
}
A for loop to print out the sum of all even numbers between 1 and 20.
What is...
int sum = 0;
for(int i=1; i<=20; i++){
if(i%2==0)
sum+=i;
}
System.out.print(sum);
A while loop to calculate the factorial of a variable named: num.
int factorial = 1;
int i = 1;
while(i <= num){
factorial *= i;
i++;
}
The error(s) in the following code:
for(int i=3; i<0; i++)
System.out.println(i);
What is...
for(int i=3; i<0; i++)
System.out.println(i);
A for loop to print out the number of characters in a String named 's'. (not including spaces).
What is....
int count = 0;
for(int i=0; i< s.length(); i++){
if(s.charAt(i) != " ")
count++;
}
System.out.println(count);
A while loop to calculate the sum of the squares of every number from 1 to 100.
What is...
int sum = 0;
int i = 1;
while(i<=100){
sum += Math.pow(i, 2);
i++;
}
The error(s) in the following code:
int i=-1;
while(i<0){
System.out.println(i);
i--;
}
What is...
int i=-1;
while(i<0){
System.out.println(i);
i++;
}