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 table of any number using a do-while loop in Java

Run it Now
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		int num;
		Scanner sc = new Scanner(System.in);
		System.out.println("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