Multiplication Table Number Pattern in C

Beginner
⏱️ 6 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Nested Loops

What You’ll Learn

How to print a triangular multiplication table pattern in C. Row i prints the multiples i×1 through i×i.

⭐ Pattern Output

For rows = 10, the pattern looks like this:

Output
1
2 4
3 6 9
4 8 12 16
5 10 15 20 25
6 12 18 24 30 36
7 14 21 28 35 42 49
8 16 24 32 40 48 56 64
9 18 27 36 45 54 63 72 81
10 20 30 40 50 60 70 80 90 100
1

Complete C Program

The outer loop selects the row number, and the inner loop multiplies that row number by 1..i.

c
#include <stdio.h>

int main() {
    int i, j;

    for (i = 1; i <= 10; i++) {
        for (j = 1; j <= i; j++) {
            printf("%d ", i * j);
        }
        printf("\n");
    }

    return 0;
}

🧠 How It Works

1

Outer loop sets the row

for (i = 1; i <= rows; i++) chooses which multiplication table row to print.

Rows
2

Inner loop prints i×j

for (j = 1; j <= i; j++) prints products from i×1 up to i×i.

Columns
3

Perfect squares on the diagonal

The last value printed on row i is i*i (a perfect square).

Insight
=

Triangular multiplication table

Total printed values are 1+2+…+n = n(n+1)/2.

2

Variation — User Input Version

Read the number of rows at runtime using scanf().

c
#include <stdio.h>

int main() {
    int i, j;
    int rows;

    printf("Enter the number of rows: ");
    scanf("%d", &rows);

    for (i = 1; i <= rows; i++) {
        for (j = 1; j <= i; j++) {
            printf("%d ", i * j);
        }
        printf("\n");
    }

    return 0;
}

💡 Tips for Enhancement

Try These

  • Align columns using printf("%4d ", i * j)
  • Print a full rectangular table by looping j to a fixed max
  • Compute row sums to practice accumulation

Avoid

  • Forgetting printf("\\n") after each row
  • Using negative rows without validation

Key Takeaways

1

Row i prints multiples from i×1 to i×i.

2

The diagonal values are perfect squares (i×i).

3

Total printed values are n(n+1)/2, so time complexity is O(n²).

4

Nested loops are the key tool for table/grid patterns.

❓ Frequently Asked Questions

Because the inner loop runs from 1 to i, so row i prints exactly i values.
Change the inner loop to a fixed limit, e.g. for (j = 1; j <= 10; j++).
O(n²) for n rows.

Explore More C Number Patterns!

Keep practicing multiplication and nested loops with new patterns.

All Number Patterns →
Did you know?

The total numbers printed for n rows are \(1+2+\dots+n = \frac{n(n+1)}{2}\).

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful