Java Program to print table of any number using a do-while loop
In this program, You will learn how to print a table of any number using a do-while loop in java.
Table is: 12 24 36 48 60 72 84 96 108 120
Example: How to print a table of any number using a do-while loop in java.
import java.util.Scanner;
class Main {
public static void main(String args[]) {
int num;
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number:");
num = sc.nextInt();
int i = 1;
do {
System.out.println(i * num);
i++;
} while (i <= 10);
}
}
Output:
Enter a number:12
12
24
36
48
60
72
84
96
108
120