Multiplication Table

This program prints the multiplication table for a given number.
Perfect for practicing loops and user input in Java.

Java Code
// Java program to print multiplication table of a number
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.println("enter a number");
        int number = scanner.nextInt(); // Read the input number
        
        // Loop to print the multiplication table
        for (int i = 1; i <= 10; i++) {
            System.out.println(number + " x " + i + " = " + (number * i));
        }
    }
}
    
Output
Enter a number