ad

Saturday, March 22, 2025

C Program to Print Pascal's Triangle

C Program

C Program to Print Pascal's Triangle

C Program to Print Pascal's Triangle 

Example 

#include<stdio.h>

int main()

{

    int  row,coef=1,space,i,j;

    printf("enter the number");

    scanf("%d",&row);

    for (i=0;i<row;i++)

    {
    for(space=1;space<=row -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");

    }

return 0;

}


C Program to Print Pascal's Triangle 

 Program Output :- 



Related Post :-


C program number pattern

No comments:

Post a Comment