Java program to print table of number

In this post we will see how to print table of number in java.

It is good program to practice for loop in java.

import java.util.Scanner;

public class TableOfNumber
{
    public static void main(String args[]){
        int number, i, table;
        Scanner scan = new Scanner(System.in);

        System.out.print("Enter a Number : ");
        number = scan.nextInt();

        System.out.print("Table of " + number + " is\n");
        for(i=1; i<=10; i++){
            table = number*i;
            System.out.print(number + " * " + i + " = " + table + "\n");
        }
    }
}

Output:

Enter a Number : 8
Table of 8 is
8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
8 * 10 = 80

That's all about how to print table of number in java.

[social_share share_on="facebook,twitter,linkedin,whatsapp"][post_navigator in_same_term="true"]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.