summaryrefslogtreecommitdiff
path: root/659/CH6/EX6.1cs/Casestudy6_1.sce
blob: 0420199b9b669849006aee5708486f72ace816d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//                  Case Study:-Chapter 6, Page No:176
//             1.Table of Binomial Coefficients

MAX=10;
printf("mx");
for m=0:10
    printf("%4d",m);
end
printf("\n-----------------------------------------------\n");
m=0;
//print the table of binomial coefficients for m=10
//Computation using while loop
while(m<=MAX)
    printf("%2d",m);
    x=0;
    binom=1;
    while(x<=m)
        if(m==0|x==0)
            printf("%4d",binom);    //Print the result i.e. binom
        else
            binom=binom*(m-x+1)/x;  //compute the binomial coefficient
            printf("%4d",binom);    //Print the result i.e. binom
        end
        x=x+1;
    end
    printf("\n");
    m=m+1;
end
printf("-----------------------------------------------\n");