blob: 9541498b7c26c238e81f45c1211ae02f51e9865e (
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
30
31
32
33
34
35
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)
|