1 | ||||||||||
1 | 1 | |||||||||
1 | 2 | 1 | ||||||||
1 | 3 | 3 | 1 | |||||||
1 | 4 | 6 | 4 | 1 |
Solution:
#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:
Note:
" Hi I am a Learner of C/C++. I have done this program with my own Knowledge. There may be an easy way to solve this program. So I am sorry if this program in your point of view is too long. "