1.4K
Table of Contents
In this article, we will be discussing various star Pattern programs in C. Usually, the value of C depends on the value of number of rows and columns.
C program Pattern 1
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
C Program:
#include<stdio.h>
int main()
{
int n;
printf("Enter the value of N:");
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
for(int z=n;z>i;z--)
{
printf(" ");
}
for(int j=1;j<=i*2-1;j++)
{
printf("*");
}
printf("\n");
}
for(int i=n;i>=1;i--)
{
for(int z=n;z>i;z--)
{
printf(" ");
}
for(int j=1;j<=i*2-1;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
C program Pattern 2
*
* *
* *
* *
* *
* *
* *
* *
* *
*
C Program:
#include<stdio.h>
int main()
{
int n;
printf("Enter the value of N:");
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
for(int z=n;z>i;z--)
{
printf(" ");
}
for(int j=1;j<=i*2-1;j++)
{
if(j==1 || j==i*2-1)
printf("*");
else
printf(" ");
}
printf("\n");
}
for(int i=n;i>=1;i--)
{
for(int z=n;z>i;z--)
{
printf(" ");
}
for(int j=1;j<=i*2-1;j++)
{
if(j==1||j==i*2-1)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}
C program Pattern 3
*
* *
* * *
* * * *
* * * * *
* * * * *
* * * *
* * *
* *
*
C Program:
#include<stdio.h>
int main()
{
int n;
printf("Enter the value of N:");
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
for(int i=n;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
C program Pattern 4
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
C Program:
#include<stdio.h>
int main()
{
int n;
printf("Enter the value of N:");
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
for(int j=n;j>=i;j--)
{
printf("*");
}
for(int z=1;z<i;z++)
{
printf(" ");
}
for(int z=1;z<i;z++)
{
printf(" ");
}
for(int j=i;j<=n;j++)
{
printf("*");
}
printf("\n");
}
for(int i=n;i>=1;i--)
{
for(int j=n;j>=i;j--)
{
printf("*");
}
for(int z=1;z<i;z++)
{
printf(" ");
}
for(int z=1;z<i;z++)
{
printf(" ");
}
for(int j=i;j<=n;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
C program Pattern 5
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
C Program:
#include<stdio.h>
int main()
{
int n;
printf("Enter the value of N:");
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
printf("*");
}
for(int z=i;z<n;z++)
{
printf(" ");
}
for(int z=i;z<n;z++)
{
printf(" ");
}
for(int j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
for(int i=n;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
printf("*");
}
for(int z=i;z<n;z++)
{
printf(" ");
}
for(int z=i;z<n;z++)
{
printf(" ");
}
for(int j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
If you like this article on Star Pattern Programs in C .Don’t forget to Share.