Filled Under: ,

C program to print Pascal Triangle

C program to print Pascal Triangle

C program to print Pascal Triangle

 In this program, I have discussed about the C program to print Pascal triangle.


#include<stdio.h>
int main()
{
int row,coef=1,sp,i,j;
printf("Enter the number:");
scanf("%d",&row);
for(i=0;i<row;i++)
{
for(sp=1;sp<=row-i;sp++)
printf(" ");
for(j=0;j<=i;j++)
{
if(j==0||i==0)
coef=1;
else
coef=coef*(i-j+1)/j;
printf("%d ",coef);
}
printf("\n");
}
}

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

0 comments:

Post a Comment

 

Copyright 2020 Programming in C All Right Reserved