Predict the output:
int i=1;
while(i++<=3)
{
i++;
System.out.print(i+" ");
}
System.out.println(i);
}
Answers
Answered by
1
Answer:
3 5 6
Explanation:
public class MyClass {
public static void main(String args[]) {
int i=1;
while(i++<=3)
{
i++;
System.out.print(i+" ");
}
System.out.println(i);
}
}
while checks 1<=3 (true) print (1++ => 2++ =>3)
while checks 3<=3 (true) print(3++ =>4++ => 5)
while checks 5<=3 (false) print(5++ => 6)
Similar questions