Print Multiplication Table in C, C++, Java & Python – Code with Explanation & Examples in Short and Simple

   

C Program

/* C - Print Multiplication Table */
#include <stdio.h>
int main(){
    int n; scanf("%d",&n);
    for(int i=1;i<=10;i++)
        printf("%d x %d = %d\n", n, i, n*i);
    return 0;
}

C Output

Input:  
5  

Output:  
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50


C++ Program

// C++ - Print Multiplication Table
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin>>n;
    for(int i=1;i<=10;i++)
        cout<<n<<" x "<<i<<" = "<<n*i<<"\n";
}

C++ Output

Input:  
7

Output:  
7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42
7 x 7 = 49
7 x 8 = 56
7 x 9 = 63
7 x 10 = 70


JAVA Program

// Java - Print Multiplication Table
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    for(int i=1;i<=10;i++)
      System.out.println(n+" x "+i+" = "+(n*i));
  }
}

JAVA Output

Input:  
3 

Output:  
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
3 x 6 = 18
3 x 7 = 21
3 x 8 = 24
3 x 9 = 27
3 x 10 = 30


Python Program

# Python - Print Multiplication Table
n = int(input())
for i in range(1, 10+1):
    print(f"{n} x {i} = {n*i}")

Python Output

Input:  
9 

Output:  
9 x 1 = 9
9 x 2 = 18
9 x 3 = 27
9 x 4 = 36
9 x 5 = 45
9 x 6 = 54
9 x 7 = 63
9 x 8 = 72
9 x 9 = 81
9 x 10 = 90


In-Depth Learning – Entire Concept in Paragraphs
Example
For an input of 5, the program outputs a well-aligned multiplication table for 5 x 1 = 5 up to 5 x 10 = 50. The loop guarantees that we multiply the input number by every number from 1 to 10 and display the operation and result.

Real-Life Analogy
Imagine multiplication tables as a recipe card for a chef — once you have the original recipe for one person, you can multiply the ingredients for 2, 3, or more. The loop serves as an assistant that does it over and over again, maintaining the same format.

Why It Matters
Practice creating multiplication tables is one of the easiest and most effective exercises for starters. It involves loops, mathematical operations, and formatted output. In actual systems, such logic is employed in generating price lists, stock reports, and calculation sheets where an initial base value is varied predictably.

Learning Insights
This exercise enhances knowledge of for-loops and how the counter variable shifts during each cycle. It also instructs in output formatting, which is essential for user-friendly programs. The program is written in the simplest way possible, avoiding extra variables — using the loop variable directly keeps the logic concise and understandable. Moreover, the loop bound (10) can be adjusted with ease to create longer or shorter tables.

Interview Relevance and Practical Use
Although "Print Multiplication Table" is not typically a direct interview question, it's a great warm-up exercise to cover fundamental loop control, arithmetic, and output formatting abilities. It also leads the way to pattern generation, nested loops, and math tables applied to data analysis or automation scripts. In practical applications, analogous loops appear in payroll computations, monthly calendars, or time tables.

Performance and Edge Notes
Time complexity is O(1) in real life because the loop is always executed a constant number of times (10 in this case). Space complexity is O(1) as no extra space is needed except for some variables. For big tables, the same principle still applies — you just set the loop limit to the chosen range.

SEO-friendly summary
This C, C++, Java, and Python multiplication table program prints the table of any provided number up to 10 and is a valuable first-step exercise in loops, arithmetic, and formatted printing. It iterates from numbers 1 through 10 and prints every multiplication step in an understandable and user-friendly format. This is ideal for studying programming fundamentals, practice coding problems, and knowing how to organize repetitive computations, which can be extended to producing price lists, schedules, and automated reports in real-world projects.