1 | ||||||||||
1 | 1 | |||||||||
1 | 2 | 1 | ||||||||
1 | 3 | 3 | 1 | |||||||
1 | 4 | 6 | 4 | 1 |
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,i,j,d[30],t[30];
clrscr();
printf("Enter the max limit:");
scanf("%d",&a);
b=a;
for(i=0;i< a;i++)
{
//Initialisation..
t[0]=1; t[i]=1;d[0]=1;
//Spacing..
for(j=0;j< b-1;j++)
printf(" ");
b--;
//Calculation..
for(j=1;j<=i;j++)
{
d[j]=t[j-1]+t[j];
}
d[i]=1;
//Printing..
for(j=0;j<=i;j++)
{
printf("%d ",d[j]);
t[j]=d[j]; //Restoring temporary Array..
}
printf("\n");
}
getch();
}
Sample Output:
No comments:
Post a Comment
Let Us hear Your thoughts about this Post.. Its Our Pleasure to get your feedback..