Skip to content

Powers of 10

Print powers of 10 using a loop.

package DSA.Flow_control;
import java.util.Scanner;
public class expof10 {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
int counter = 0;
while (true) {
System.out.println("Enter a Number");
int i = sc.nextInt();
if (i % 10 == 0) {
continue;
} else if (i == -1) {
break;
}
System.out.println(counter);
counter++;
}
} catch (Exception e) {
System.out.println(e);
}
}
}