Skip to main content

← Back to Overview

Java Program - Multiplication Table

Concept Explanation

What is it?

This program takes an integer input from the user and prints its multiplication table from 1 to 10.


Algorithm

  1. Start
  2. Input a number n.
  3. Start a loop from i = 1 up to 10.
  4. Inside the loop, calculate product = n * i.
  5. Print the result in the format "n * i = product".
  6. End

Implementations

import java.util.Scanner;

public class MultiplicationTable {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

System.out.print("Enter a number: ");
int n = sc.nextInt();

System.out.println("Multiplication Table for " + n + ":");
System.out.println("---------------------------");

for (int i = 1; i <= 10; i++) {
System.out.println(n + " x " + i + " = " + (n * i));
}

sc.close();
}
}

Complexity Analysis

  • Time Complexity: O(1) - The loop always runs exactly 10 times.
  • Space Complexity: O(1)

Flowchart



"Repeat until the logic is flawless." - Anonymous

📍 Visit Us

🏫 VD Computer Tuition Surat

VD Computer Tuition
📍 Address
2/66 Faram Street, Rustompura
Surat395002, Gujarat, India
📞 Phone / WhatsApp
+91 84604 41384
🌐 Website

Computer Classes & Tuition — Areas We Serve in Surat

AdajanAlthanAmroliAthwaAthwalinesBhagalBhatarBhestanCanal RoadChowkCitylightDumasGaurav PathGhod Dod RoadHaziraJahangirpuraKamrejKapodraKatargamLimbayatMagdallaMajura GateMota VarachhaNanpuraNew CitylightOlpadPalPandesaraParle PointPiplodPunaRanderRing RoadRustampuraSachinSalabatpuraSarthanaSosyo CircleUdhnaVarachhaVed RoadVesuVIP Road
📞 Call Sir💬 WhatsApp Sir