/* Write a C Program to print binomial coefficient table. */
==========================================
#include<stdio.h>
#include<conio.h>
#define MAX 10
void main()
{
int m, x, binom;
printf(“m x”);
for (m=0; m<=10; ++m)
m=0;
do
{
printf(“%2d”, m);
X=0; biom=1;
while(x<=m)
{
if(m= =0 || x= =0)
printf(“%4d”, binom);
else
F
CP
61
UNDAMENTALS
ROGRAMS
{
binom=binom* (m-x+1)/x;
printf(“%4d”, binom);
}
x=x+1;
}
printf(“\n”);
M=m+1’
}
while(m<=MAX);
}
Output:
======
Mx0123 4 5 6 7 89 10
01
011
2121
31331
414641
515101051
61615201561
7 17213535217 1
8 1828567056288 1
9 1 9 36 84 126 126 84 36 9 1
10 1 10 45 120 210 252 210 120 45 10 1
==========================================
#include<stdio.h>
#include<conio.h>
#define MAX 10
void main()
{
int m, x, binom;
printf(“m x”);
for (m=0; m<=10; ++m)
m=0;
do
{
printf(“%2d”, m);
X=0; biom=1;
while(x<=m)
{
if(m= =0 || x= =0)
printf(“%4d”, binom);
else
F
CP
61
UNDAMENTALS
ROGRAMS
{
binom=binom* (m-x+1)/x;
printf(“%4d”, binom);
}
x=x+1;
}
printf(“\n”);
M=m+1’
}
while(m<=MAX);
}
Output:
======
Mx0123 4 5 6 7 89 10
01
011
2121
31331
414641
515101051
61615201561
7 17213535217 1
8 1828567056288 1
9 1 9 36 84 126 126 84 36 9 1
10 1 10 45 120 210 252 210 120 45 10 1
No comments:
Post a Comment