#include<stdio.h>
#include<conio.h>
void main()
{
int num,i,j,k,l,m,a[9][9];
X: clrscr();
printf("\n\n Enter the number of level u wanna print in a Pascal Triangle (Max. 9):");
scanf("%d",&num);
if(num>9)
{ goto X; }
printf("\n\n The Following Pascal Triangle is : \n\n");
for(i=0;i<=num;i++)
{
k = num-i;
for(j=1;j<=k;j++)
{ printf(" "); }
for(l=0;l<=i;l++)
{
if( l==0 || l==i )
a[i][l]=1;
else
{
a[i][l] = a[i-1][l] + a[i-1][l-1];
}
printf("%d ",a[i][l]);
}
for(j=1;j<=k+2;j++)
{ printf(" "); }
printf(" n=%d \n",i);
}
getch();
}
#include<conio.h>
void main()
{
int num,i,j,k,l,m,a[9][9];
X: clrscr();
printf("\n\n Enter the number of level u wanna print in a Pascal Triangle (Max. 9):");
scanf("%d",&num);
if(num>9)
{ goto X; }
printf("\n\n The Following Pascal Triangle is : \n\n");
for(i=0;i<=num;i++)
{
k = num-i;
for(j=1;j<=k;j++)
{ printf(" "); }
for(l=0;l<=i;l++)
{
if( l==0 || l==i )
a[i][l]=1;
else
{
a[i][l] = a[i-1][l] + a[i-1][l-1];
}
printf("%d ",a[i][l]);
}
for(j=1;j<=k+2;j++)
{ printf(" "); }
printf(" n=%d \n",i);
}
getch();
}
No comments:
Post a Comment