Multiplication Table Number Pattern in C

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:
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 100Complete C Program
The outer loop selects the row number, and the inner loop multiplies that row number by 1..i.
#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
Outer loop sets the row
for (i = 1; i <= rows; i++) chooses which multiplication table row to print.
Inner loop prints i×j
for (j = 1; j <= i; j++) prints products from i×1 up to i×i.
Perfect squares on the diagonal
The last value printed on row i is i*i (a perfect square).
Triangular multiplication table
Total printed values are 1+2+…+n = n(n+1)/2.
Variation — User Input Version
Read the number of rows at runtime using scanf().
#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
jto a fixed max - Compute row sums to practice accumulation
Avoid
- Forgetting
printf("\\n")after each row - Using negative
rowswithout validation
Key Takeaways
Row i prints multiples from i×1 to i×i.
The diagonal values are perfect squares (i×i).
Total printed values are n(n+1)/2, so time complexity is O(n²).
Nested loops are the key tool for table/grid patterns.
❓ Frequently Asked Questions
1 to i, so row i prints exactly i values.for (j = 1; j <= 10; j++).n rows.Explore More C Number Patterns!
Keep practicing multiplication and nested loops with new patterns.
The total numbers printed for n rows are \(1+2+\dots+n = \frac{n(n+1)}{2}\).
12 people found this page helpful
