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

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.