Star Pattens, many of you would have seen these types of star pattern programs in your college years. It's a hectic process to make them but it's not as difficult as you think it is.
Do you want to make these star patterns easily using the C language?
Here is the tutorial where you will learn how to make Square Star Patterns, Hollow Square Star, Hollow Squares with Diagonal, Hollow Rhombus, Rhombus Star, Hollow Mirrored Rhombus, Right Triangles, and many patterns in C programming language.
Let's dive into this amazing tutorial and help you make the star pattern in C easily!
1. Square Star Pattern Programs
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
printf("* ");
}
printf("\n");
}
return 0;
}

2. Hollow Square Star Pattern Program
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
if(i == 1 || i == n || j == 1 || j == n)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}

3. Hollow Square Pattern with Diagonal
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
if(i == 1 || i == n || j == 1 || j == n - i + 1 || i == j || j == n)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}

4. Rhombus Star Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = n; i >= 1; i--) {
for(int j = 1; j <= i - 1; j++) {
printf(" ");
}
for(int k = 1; k <= n; k++) {
printf("*");
}
printf("\n");
}
return 0;
}

5. Hollow Rhombus Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = n; i >= 1; i--) {
for(int j = 1; j <= i - 1; j++) {
printf(" ");
}
for(int k = 1; k <= n; k++) {
if(i == 1 || i == n || k == 1 || k == n)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}

6. Mirrored Rhombus Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j < i; j++) {
printf(" ");
}
for(int k = 1; k <= n; k++) {
printf("*");
}
printf("\n");
}
return 0;
}

7. Hollow Mirrored Rhombus Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j < i; j++) {
printf(" ");
}
for(int k = 1; k <= n; k++) {
if(i == 1 || i == n || k == 1 || k == n)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}

8. Right Triangle Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 1;i <= n; i++) {
for(int j = 1; j <= i; j++) {
printf("* ");
}
printf("\n");
}
return 0;
}

9. Hollow Right Triangle Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 1;i <= n; i++) {
for(int j = 1; j <= i; j++) {
if(j==1|| i==j || i==n )
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}

10. Mirrored Right Triangle Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int m = 1;
for(int i = n; i >= 1; i--) {
for(int j = 1; j <= i - 1; j++) {
printf(" ");
}
for(int k = 1; k <= m; k++) {
printf("*");
}
printf("\n");
m++;
}
return 0;
}

11. Hollow Mirrored Right Triangle Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int m = 1;
for(int i = n; i >= 1; i--) {
for(int j = 1; j <= i - 1; j++) {
printf(" ");
}
for(int k = 1; k <= m; k++) {
if(k == 1 || k == m || m == n)
printf("*");
else
printf(" ");
}
printf("\n");
m++;
}
return 0;
}

12. Inverted Right Triangle Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = n; i >= 1; i--) {
for(int j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}

13. Hollow Inverted Right Triangle Star Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = n; i >= 1; i--) {
for(int j = 1; j <= i; j++) {
if(j == 1 || j == i || i == n)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}

14. Inverted Mirrored Right Triangle Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int m = n;
for(int i = 1;i <= n; i++) {
for(int j = 1; j < i; j++) {
printf(" ");
}
for(int k = 1; k <= m; k++) {
printf("*");
}
m--;
printf("\n");
}
return 0;
}

15. Hollow Inverted Mirrored Right Triangle Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int m = n;
for(int i = 1; i <= n; i++) {
for(int j = 1; j < i; j++) {
printf(" ");
}
for(int k = 1; k <= m; k++) {
if(i == 1 || k == 1 || k == m)
printf("*");
else
printf(" ");
}
m--;
printf("\n");
}
return 0;
}

16. Pyramid Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int m = n;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m - 1; j++) {
printf(" ");
}
for(int k = 1; k <= 2 * i - 1; k++) {
printf("*");
}
m--;
printf("\n");
}
return 0;
}

17. Hollow Pyramid Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int m = n;
for(int i = 1; i <= n; i++) {
for(int j= 1; j<= m - 1; j++) {
printf(" ");
}
for(int k = 1; k <= 2 * i - 1; k++) {
if(k == 1 || k == 2 * i - 1 || i == n)
printf("*");
else
printf(" ");
}
m--;
printf("\n");
}
return 0;
}

18. Inverted Pyramid Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int m = 1;
for(int i = n; i >= 1; i--) {
for(int j = 1; j < m; j++) {
printf(" ");
}
for(int k = 1; k <= 2 * i - 1; k++) {
printf("*");
}
m++;
printf("\n");
}
return 0;
}

19. Hollow Pyramid Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int m = 1;
for(int i = n; i >= 1; i--) {
for(int j = 1; j < m; j++) {
printf(" ");
}
for(int k = 1; k <= 2 * i - 1; k++) {
if(k == 1 || k == 2 * i - 1 || i == n)
printf("*");
else
printf(" ");
}
m++;
printf("\n");
}
return 0;
}

20. Half Diamond Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
for(int i = n - 1; i >= 1; i--) {
for(int j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}

21. Diamond Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int spaces = n - 1, characters = 1;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= spaces; j++) {
printf(" ");
}
for(int k = 1; k <= characters; k++) {
printf("*");
}
if(spaces > i) {
spaces = spaces - 1;
characters = characters + 2;
}
if(spaces < i) {
spaces = spaces + 1;
characters = characters - 2;
}
printf("\n");
}
return 0;
}

22. Right Arrow Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 0; i < n; i++) {
for(int j = 0; j < i; j++) {
printf(" ");
}
for(int k = 1; k <= n - i; k++) {
printf("*");
}
printf("\n");
}
for(int i = 1; i < n; i++) {
for(int j = 1; j < n - i; j++) {
printf(" ");
}
for(int k = 1; k <= i + 1; k++) {
printf("*");
}
printf("\n");
}
return 0;
}

23. Left Arrow Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n - i; j++) {
printf(" ");
}
for(int k=0;k<=n-i;k++) {
printf("*");
}
printf("\n");
}
for(int i = 1; i < n; i++) {
for(int j = 1; j < i + 1; j++) {
printf(" ");
}
for(int k = 1; k <= i + 1; k++) {
printf("*");
}
printf("\n");
}
return 0;
}

24. Plus Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
for(int i = 1; i <= n; i++) {
if(i == ((n / 2) + 1)) {
for(int j = 1; j <= n; j++) {
printf("+");
}
}
else {
for(int j = 1; j <= n / 2; j++) {
printf(" ");
}
printf("+");
}
printf("\n");
}
return 0;
}

25. X Pattern
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int m = 2 * n - 1;
for(int i = 1; i <= m; i++) {
for(int j = 1; j <= m; j++) {
if(i == j || j == (m - i + 1)) {
printf("*");
}
else {
printf(" ");
}
}
printf("\n");
}
return 0;
}

Conclusion
This article has presented a comprehensive list of star pattern programs in the C programming language, including Square Star Patterns, Hollow Square Stars, Hollow Squares with Diagonal, Rhombus Stars, Hollow Rhombus, Mirrored Rhombus, Hollow Mirrored Rhombus, Right Triangles, and many more. Each of these programs is explained with the help of the source code, making it easy for you to understand and implement them. We also make sure to cover almost every pattern that we can do with C programming.
If you are still wondering how we did it, you can learn C programming language for absolutely free with our easy-to-use and interactive course.
Frequently Asked Questions(FAQs)
1. What is star pattern in C?
Star pattern in C programming language are shapes that are made up of * or any other symbols. You can make these types of shapes with any programming language.
2. How to print a star pattern in C?
To print a star pattern in C, you have to write a program in C and run it. Here is an example-
#include <stdio.h>
int main()
{
int n;
printf("Enter the number of rows in your pattern: ");
scanf("%d",&n);
int m = 1;
for(int i = n; i >= 1; i--) {
for(int j = 1; j < m; j++) {
printf(" ");
}
for(int k = 1; k <= 2 * i - 1; k++) {
printf("*");
}
m++;
printf("\n");
}
return 0;
}
This is the output of this code -

3. How can I learn to create star pattern programs in C language?
You can learn to create star pattern programs in C language by studying tutorials and examples online or in programming books or learn C language for absolutely free with Studytonight's easy-to-use and interactive course.
4. What are some popular star pattern programs in C language?
Some popular star pattern programs in C language include square star patterns, hollow square star patterns, hollow squares with diagonal, rhombus star patterns, hollow rhombus patterns, mirrored rhombus patterns, and right triangle patterns.
You May Also Like: