diff options
Diffstat (limited to '3808/CH6/EX6.14/Ex6_14.sce')
-rw-r--r-- | 3808/CH6/EX6.14/Ex6_14.sce | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/3808/CH6/EX6.14/Ex6_14.sce b/3808/CH6/EX6.14/Ex6_14.sce new file mode 100644 index 000000000..9541498b7 --- /dev/null +++ b/3808/CH6/EX6.14/Ex6_14.sce @@ -0,0 +1,36 @@ +//Chapter 06: Counting + +clc; +clear; + +function result=combination(n,r) //function definition +i=n +num=1 +denominator=1 +l=(n-r)+1 +u=n +for i=l:u //to compute the value of the numerator +num=num*i +end +for j=1:r //to compute the value of the denominator +denominator=denominator*j +end +result=num/denominator +return result +endfunction + +num1=input("Enter the total number of faculty in Computer Science department:") +com1=input("Enter the number of faculty to be selected for the Computer Science department:") +res1=combination(num1,com1) + +mprintf("The number of combinations for the Computer Science department is %d ",res1) + +num2=input("Enter the total number of faculty in the Maths department:") +com2=input("Enter the number of faculty to be selected for the Maths department:") +res2=combination(num2,com2) + +mprintf("The number of combinations for the Maths department is %d ",res2) + +final_res=res1*res2 + +mprintf("The total number of combinations for the selected faculties is %d",final_res) |