Computer Applications
Identify all the errors in the following repetitive statements.
while (x == y)
{
xx = yy;
x = y;
}
Java Iterative Stmts
2 Likes
Answer
The test expression x == y
will always remain true
as in each iteration x = y
is executed, which will store the value of y
in x
. Thus, an infinite loop will be generated.
Answered By
1 Like
Related Questions
Convert the following for loop statement into the corresponding while loop and do-while loop:
int sum = 0; for (int i= 0; i <= 100; i++) sum = sum + i;
Identify all the errors in the following repetitive statements.
for (int i = 5; i > 0; i++) { System.out.println("Java"); }
What is an empty statement? Explain its usefulness.
Identify all the errors in the following repetitive statements.
while (z < 1 && z > 100) { a = b; }