Java program that takes a number as input and prints its multiplication table upto 10

import java.util.Scanner;

public class Table{
    public static void main(String args[]){
        int num,table = 1,limit = 10;
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter any number :");
        //Takes input from user
        num = scanner.nextInt();
        for(int i = 1; i<=limit; i++){
            table = num * i;
            System.out.println(num+" x " + i + " = "+table);
            table = 1;
        }
    }
}

Output

Enter any number :
4
4 x 1 = 4
4 x 2 = 8
4 x 3 = 12
4 x 4 = 16
4 x 5 = 20
4 x 6 = 24
4 x 7 = 28
4 x 8 = 32
4 x 9 = 36
4 x 10 = 40

Leave a Reply