Java Program to print table of any number


In this program, You will learn how to print a table of any number in java.


Table is: 16 32 48 64 80 96 112 128 144 160

Example: How to print a table of any number in java

import java.util.Scanner;

class Main {
    public static void main(String args[]) {

        int i, n;
        Scanner sc = new Scanner(System.in);

        System.out.print("Enter a number:");
        n = sc.nextInt();
        System.out.println("Table is:");

        for (i = 1; i <= 10; i++) {
            System.out.println(n +" * "+i +" "+n * i);
        }

    }
}

Output:

Enter a number:16
Table is:
16 * 1 16
16 * 2 32
16 * 3 48
16 * 4 64
16 * 5 80
16 * 6 96
16 * 7 112
16 * 8 128
16 * 9 144
16 * 10 160