Google Ads

Wednesday, May 27, 2009

Pascal's Triangle


PASCAL’S TRIANGLE

#include”stdio.h”

#include “conio.h”

void main()

{

int i,a,b,n;

clrscr();

printf("\n\n\n\t\t\tPASCAL’S TRIANGLE\n");

printf("\t\t\t***************\n\n\n");

printf("\nEnter the Limit : ");

scanf("%d",&n);

for(i=0;i

{

a=0;

b=1;

printf("\n");

while(a<=i)

{

if((a==0)||(i==0))

{

printf("\t%d",b);

}

else

{

b=b*(i-a+1)/a;

printf("\t%d",b);

}

a++;

}

}

getch();

}

Output will be

Enter the Limit : 6

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1


No comments:

Post a Comment