Computer Applications
Find out the error(s) in the following code and underlining correct error(s).
int m = 5; n = 10;
while(n >= 1)
{
System.out.print("m");
n--;
}
Java Iterative Stmts
5 Likes
Answer
There are two errors in this code:
- Variable n is not declared.
- Instead of printing variable m, string "m" is printed inside the loop.
int m = 5, n = 10; //correction 1
while(n >= 1)
{
System.out.print(m); //correction 2
n--;
}
Answered By
5 Likes