Multiplication Table

Print the multiplication table of a given number.

BeginnerTopic: Module 3: Loop Programs
Back

Java Multiplication Table Program

This program helps you to learn the fundamental structure and syntax of Java programming.

Try This Code
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = sc.nextInt();

        for (int i = 1; i <= 10; i++) {
            System.out.println(n + " x " + i + " = " + (n * i));
        }
        sc.close();
    }
}
Output
Enter a number: 5
5 x 1 = 5
5 x 2 = 10
...
5 x 10 = 50

Understanding Multiplication Table

We loop i from 1 to 10 and print n × i each time.

Note: To write and run Java programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Java Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Java programs.

Table of Contents