Â
In this, we are going to see a program in which we will print the pattern of Pascal's Triangle as shown in the image above in C programming Language.
//WAP to create Pascal's Triangle Pattern
#include <stdio.h>
void main()
{
int n, coef = 1, space, i, j;
printf("Enter the number of Rows: ");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
for (space = 1; space <= n - i; space++)
{
printf(" ");
}
for (j = 0; j <= i; j++)
{
if (j == 0 || i == 0)
{
coef = 1;
}
else
{
coef = coef * (i - j + 1) / j;
}
printf("%4d", coef);
}
printf("\n");
}
}
#ENJOY CODING
Need a pyramid with * symbol
ReplyDeletehttps://www.helpforcoders.com/2021/07/pyramid-pattern-type-1.html
DeleteIt has the code, just instead of # print * in printf statement
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP