/* PASCAL TRIANGLE */
#include<stdio.h>
#include<conio.h>
main()
{
int i,j,k,n,x=1;
clrscr();
printf("\n Enter number of rwos: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=40-i;j>=1;j--)
{
printf(" ");
}
for(k=1;k<=i;k++)
{
if(k==1)
{
x=1;
printf("%d\t",x);
}
else
{
x=x*(i-k+1)/(k-1);
printf("%d\t",x);
}
}
printf("\n");
}
getch();
}
No comments:
Post a Comment