Computer Applications
Rewrite the following program segment using while instead of for loop.
int f = 1, i;
for(i = 1; i <= 5 ; i++)
{
f *= i;
System.out.println(f);
}
Java Iterative Stmts
7 Likes
Answer
int f = 1; i = 1;
while(i <= 5) {
f *= i;
System.out.println(f);
i++;
}
Answered By
5 Likes
Related Questions
Write the values that will be stored in variables num and sum after execution of the following code.
int sum = 0, num = -2; do { sum = sum + num; num++; } while (num < 1);The following code has some error(s). Rewrite the correct code and underlining all the corrections made.
integer counter = 0; i = 10; num; for (num = i; num >= 1; num--); { If i % num = 0 { counter = counter + 1; } }State the method that
(a) converts a string to a primitive float data type.
(b) determines if the specified character is an uppercase character.
Write the Java statement for the following mathematical expression: