Introduction :
Creating different types of pattern is a common task in programming. Using the C programming language, you can generate various patterns. Using the pattern programs, you can improve your problem solving abilities. This also helps you to improve your programming logic. In this article, I shall show you how to create different types of pattern in C programming language.
How run the all program :
To run the program on your PC, first install VS Code. Then, open the VS Code and create a new file like “pac.c”. Then, copy paste the below code of programs one by one in the “pac.c” file. Now, save and run all the file one by one on your PC. Here, I use printf() and scanf() functions to display output on console screen and take input from the users respectively.
Source code of all program :
The following codes are the source code of all pattern programs in C programming language. You have to copy paste the below programs one by one and run to see the output.
Example 1 :
This program generates and display the first five rows of Pascal’s Triangle in C programming language.
Code of the program :
/*Developed by Puskar Jasu*/
#include <stdio.h>
int main()
{
int i, j = 5, k = 1, m, a, x = 30, y = 5;
for (i = 1; i <= 5; i++)
{
m = k;
while (m != 0)
{
a = m % 10;
m = m / 10;
printf("%d ", a);
x += 10;
if (m == 0)
{
printf("\n");
y += 2;
x = 30 - j;
j += 5;
}
}
k = k * 11;
}
return 0;
}
Output :
After running the program on your PC, you can see the output of the program.

Example 2 :
This is an another example of Pascal’s Triangle in C programming language.
Code of the program :
/*Developed by Puskar Jasu*/
#include <stdio.h>
int main()
{
int i, j, k, l = 1;
for (i = 1; i <= 4; i++)
{
for (k = 6 - i; k >= 1; k--)
{
printf(" ");
}
l = 1;
for (j = 0; j <= i; j++)
{
printf("%d ", l);
l = l * (i - j) / (j + 1);
}
printf("\n");
}
return 0;
}
Output :
If you run the program on your PC, you can see the output of the program like below image.

Example 3 :
This program is an example of symmetrical patterns with numbers in C programming language. The output is generated based on user input.
Code of the program :
/*Developed by Puskar Jasu*/
#include <stdio.h>
int main()
{
int i, j, k, l, n;
printf(" Enter the number ");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (k = 1; k <= i - 1; k++)
{
printf(" ");
}
for (j = 1; j <= n + 1 - i; j++)
{
printf("%d ", j);
}
for (l = n - i; l >= 1; l--)
{
printf("%d ", l);
}
printf("\n");
}
return 0;
}
Output :
When you run the program, you can see the output on your PC.

Example 4 :
This is an example of generating a pyramid of numbers in C programming language. According to user input, the number of rows in the pyramid is generated.
Code of the program :
/*Developed by Puskar Jasu*/
#include <stdio.h>
int main()
{
int num, i, j, k = 0, l;
printf("Enter row of the piramid\n");
scanf("%d", &num);
for (i = 1; i <= num; i++)
{
for (l = 1; l <= num - i; l++)
{
printf(" ");
}
for (j = 1; j <= i; j++)
{
k++;
printf(" %d", k);
}
printf("\n\n");
}
return 0;
}
Output :
After running the program, you can see the below image as output.

Example 5 :
This program generates a pyramid pattern using ASCII characters (A to H) in C programming language.
Code of the program :
/*Developed by Puskar Jasu*/
#include <stdio.h>
int main()
{
int i, j, k, l;
for (i = 1; i <= 7; i++)
{
for (j = 65; j <= 72 - i; j++)
{
printf("%c ", j);
}
for (k = 0; k <= i - 1; k++)
{
if (k == 0)
printf(" ");
else if (k == 1)
printf(" ");
else
printf(" ");
}
for (l = 72 - i; l >= 65; l--)
{
if (l == 71)
continue;
printf("%c ", l);
}
printf("\n\n");
}
return 0;
}
Output :
To see the output of the program, you can run the program on your PC.

Conclusion :
At last, you have learned how to create different type patterns in the C programming language. You can use above programs in your projects. Thank you for visiting my site.