A slanted block of stars, wider than it is tall. The logic is explained step by step, and the full program is given in C, C++, Java and Python.
Quick answer: Use n rows. On row i, print n − i spaces and then 2 × n stars, then a new line. The shrinking spaces shift each row one step left, which slants the long rows into a parallelogram. The example uses n = 4: 4 rows of 8 stars.
This program is part of the Star Patterns collection.
Table of contents8 sections
Parallelogram Star Pattern output
Output (4 rows, 8 stars per row):
******** ******** ******** ********

How the parallelogram star pattern works
Each row prints n − i spaces and then 2n stars. The shrinking indent slants the block to the left as you go down.
- Run the outer loop for
ifrom1ton, one row per pass. - Print
n − ispaces. - Print
2 × nstars. - Move to the next line.
Key takeaways
- The star count is fixed at
2 × n; the slant comes only from the leading spaces. - It is the rhombus with longer rows:
2 × nstars instead ofn. - The last row has no spaces, because
n − i = 0wheni = n. - Total stars:
2 × n × n, which is 32 forn = 4.
Parallelogram Star Pattern in C
#include <stdio.h>
int main(void) {
int n = 4;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - i; j++)
printf(" ");
for (int j = 1; j <= 2 * n; j++)
printf("*");
printf("\n");
}
return 0;
}Parallelogram Star Pattern in C++
#include <iostream>
using namespace std;
int main() {
int n = 4;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - i; j++)
cout << " ";
for (int j = 1; j <= 2 * n; j++)
cout << "*";
cout << endl;
}
return 0;
}Parallelogram Star Pattern in Java
public class ParallelogramStar {
public static void main(String[] args) {
int n = 4;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n - i; j++)
System.out.print(" ");
for (int j = 1; j <= 2 * n; j++)
System.out.print("*");
System.out.println();
}
}
}Parallelogram Star Pattern in Python
n = 4
for i in range(1, n + 1):
for j in range(1, n - i + 1):
print(" ", end="")
for j in range(1, 2 * n + 1):
print("*", end="")
print()Time and space complexity
The program prints one character for each position in the pattern, so for n rows it runs in O(n²) time. It only needs a few loop variables, so the extra memory is O(1).
Frequently asked questions
How do I change the length of the rows?
Change the limit of the star loop. 2 × n gives rows twice as long as the height; any other number, or a separate width variable, works the same way.
How do I slant it to the right instead?
Print i − 1 spaces instead of n − i; the rows then move right as you go down.
What is the difference from a rhombus?
A rhombus has as many stars per row as it has rows; a parallelogram has longer rows. Compare it with the rhombus star pattern.










