In this tutorial, we will see a simple Java program to display the multiplication table of a given number.
Print Multiplication table of a given number
In the program, user is asked to enter the number and the program prints the multiplication table of the input number using for loop. The loops run from 1 to 10 and the input number is multiplied by the loop counter in each step to display the steps of multiplication table.
Java Code: Java Program to Print Multiplication Table of a Number
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.println("Write a Java Program to Print Table of a Number"); System.out.println("Enter a Number"); int n = console.nextInt(); for (int i = 1; i <= 10; ++i) System.out.println(n + " * " + i + " = " + n * i); } |
Output: