// INPUTTING THE NO. OF LINES THROUGH KEYBOARD
#include "stdio.h"
#include "conio.h"
int factorial(unsigned long int);
void main()
{
int n,i,j,k;
unsigned long int val;
clrscr();
printf("\n\t\t\t --**:: PASCAL TRIANGLE ::**--");
do{
printf("\n Enter the no. of Lines : ");
scanf("%ld",&n);
if(n<0)
printf("\n Please Enter the correct Data");
}while(n<0);
printf("\n\n");
for(i=0;i
{
printf("\n\t\t\t");
for(k=n-1;k>=i+1;k--)
{
printf(" ");
}
for(j=0;j<=i;j++)
{
val=factorial(i)/(factorial(i-j)*factorial(j));
printf(" %ld",val);
}
}
getch();
}
int factorial(unsigned long int num)
{
unsigned long int fact=1;
while(num>0)
fact*=num--;
return (fact);
}
No comments:
Post a Comment