A rhombus number pattern is a symmetric arrangement of numbers shaped like a slanted rectangle. These patterns are excellent exercises for understanding nested loops and spacing in C. There are many variations, but in this article, we will explore four: a rhombus with increasing numbers, a rhombus with decreasing numbers, a hollow rhombus with increasing numbers, and a hollow rhombus with decreasing numbers.
Understanding The Problem
The task is to take the number of rows from the user and print a rhombus. Each row begins with leading spaces for alignment, followed by numbers arranged according to the specific variation. The logic for each pattern changes depending on whether the numbers are increasing, decreasing, or hollow.
Program 1: Rhombus with Increasing Numbers
In this variation, numbers increase from left to right in every row. The number of spaces before each row gradually decreases, which aligns the numbers to form the rhombus shape.
#include <stdio.h>
int main() {
int n;
printf("Enter number of rows: ");
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n - i; j++) {
printf(" ");
}
for(int j = 1; j <= n; j++) {
printf("%d", j);
}
printf("\n");
}
return 0;
}
This program prints a solid rhombus where each row contains numbers from 1
to n
. By carefully placing spaces before the numbers, the pattern takes the correct shape.

Program 2: Rhombus with Decreasing Numbers
This version is similar to the first program, but instead of printing numbers in increasing order, each row prints numbers from n
down to 1
. This gives a reversed look while maintaining the rhombus shape.
#include <stdio.h>
int main() {
int n;
printf("Enter number of rows: ");
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n - i; j++) {
printf(" ");
}
for(int j = n; j >= 1; j--) {
printf("%d", j);
}
printf("\n");
}
return 0;
}
Here the alignment logic is the same, but the inner loop changes direction. The numbers now decrease, producing a rhombus with a mirrored arrangement.

Program 3: Hollow Rhombus with Increasing Numbers
In this version, only the borders of the rhombus are printed with numbers, leaving the inside empty. A conditional statement checks if the position is on the boundary, and if not, a space is printed.
#include <stdio.h>
int main() {
int n;
printf("Enter number of rows: ");
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n - i; j++) {
printf(" ");
}
for(int j = 1; j <= n; j++) {
if(i == 1 || i == n || j == 1 || j == n) {
printf("%d", j);
} else {
printf(" ");
}
}
printf("\n");
}
return 0;
}
This program produces a hollow rhombus where only the outline is formed with numbers. The use of conditions ensures that the center part remains empty.

Program 4: Hollow Rhombus with Decreasing Numbers
This variation combines the hollow structure with decreasing numbers. Each row starts with spaces for alignment, and only the boundary positions print numbers in reverse order.
#include <stdio.h>
int main() {
int n;
printf("Enter number of rows: ");
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n - i; j++) {
printf(" ");
}
for(int j = n; j >= 1; j--) {
if(i == 1 || i == n || j == n || j == 1) {
printf("%d", j);
} else {
printf(" ");
}
}
printf("\n");
}
return 0;
}
This program prints a hollow rhombus with numbers decreasing from n
to 1
. The alignment logic is preserved while the conditional statements ensure only the borders are shown.

FAQs
Q1: Can all these programs be merged into one program with a menu?
Yes, you can add a menu where the user chooses which rhombus variation to print.
Q2: Can we use stars instead of numbers in these programs?
Yes, by replacing numbers with *
, the same rhombus patterns can be printed with stars.
Conclusion
The rhombus number pattern is a versatile exercise in C programming that tests both nested loops and conditional logic. With simple modifications, we can create increasing, decreasing, and hollow versions of the rhombus. These programs are excellent practice for mastering loop control and spacing in C.
References & Additional Resources
- C Programming Tutorial – Helps beginners understand loops and formatted printing.
- GeeksforGeeks – C Program to Print Number Pattern – Contains examples of various number and star patterns.
- TutorialsPoint – C Loops – Reference for nested loop concepts used in pattern printing.