Java Program to print table of any number using while loop


In this program, You will learn how to print a table of any number using a while loop in Java.


Table is: 14 28 42 56 70 84 98 112 126 140


Example: How to print table of any number using 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;

		while (i <= 10) {
			System.out.println(i*num);
			i++;
		}

	}

}

Output:

Enter a number :14
14
28
42
56
70
84
98
112
126
140