Write the following program using while loop
Attachments:
![](https://hi-static.z-dn.net/files/dba/4c0bc3299eba6acaef718765ca366b72.jpg)
Answers
Answered by
3
Given Snippet:
public class Change1 {
public static void main(String[ ] args) {
int i, b = 0, c;
System.out.println("The numbers are :");
for (i = 1; i <= 10; i++) {
c = b * b;
System.out.println(c);
b = b + 1;
}
}
}
After Converting:
public class Change1 {
public static void main(String[ ] args) {
int i = 1, b = 0, c;
System.out.println("The numbers are :");
while (i <= 10) {
c = b * b;
System.out.println(c);
b = b + 1; // b += 1 or b++
i++;
}
}
}
Short explanation about the while loop:
https://brainly.in/question/33957417
Similar questions