#include<stdio.h>
int main()
{
int n, r, s, r, ncr = 1;
printf("Enter Row Number : ");
scanf("%d", &row);
for(n=0; n<row; n++)
{
for(s=1; s<=row-n; s++)
{
printf(" ");
}
for(r=0; r<=n; r++)
{
if(n == 0 || r == 0)
{
ncr = 1;
}
else
{
ncr = ncr * (n - r + 1)/r;
}
printf("%4d", ncr);
}
printf("\n");
}
return 0;
}
int main()
{
int n, r, s, r, ncr = 1;
printf("Enter Row Number : ");
scanf("%d", &row);
for(n=0; n<row; n++)
{
for(s=1; s<=row-n; s++)
{
printf(" ");
}
for(r=0; r<=n; r++)
{
if(n == 0 || r == 0)
{
ncr = 1;
}
else
{
ncr = ncr * (n - r + 1)/r;
}
printf("%4d", ncr);
}
printf("\n");
}
return 0;
}
Comments
Post a Comment