diff options
author | prashantsinalkar | 2017-10-10 12:27:19 +0530 |
---|---|---|
committer | prashantsinalkar | 2017-10-10 12:27:19 +0530 |
commit | 7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch) | |
tree | dbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /3808/CH6 | |
parent | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff) | |
download | Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2 Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip |
initial commit / add all books
Diffstat (limited to '3808/CH6')
-rw-r--r-- | 3808/CH6/EX6.1/Ex6_1.sce | 13 | ||||
-rw-r--r-- | 3808/CH6/EX6.10/Ex6_10.sce | 25 | ||||
-rw-r--r-- | 3808/CH6/EX6.11/Ex6_11.sce | 29 | ||||
-rw-r--r-- | 3808/CH6/EX6.12/Ex6_12.sce | 25 | ||||
-rw-r--r-- | 3808/CH6/EX6.13/Ex6_13.sce | 25 | ||||
-rw-r--r-- | 3808/CH6/EX6.14/Ex6_14.sce | 36 | ||||
-rw-r--r-- | 3808/CH6/EX6.15/Ex6_15.sce | 32 | ||||
-rw-r--r-- | 3808/CH6/EX6.16/Ex6_16.sce | 29 | ||||
-rw-r--r-- | 3808/CH6/EX6.2/Ex6_2.sce | 11 | ||||
-rw-r--r-- | 3808/CH6/EX6.3/Ex6_3.sce | 11 | ||||
-rw-r--r-- | 3808/CH6/EX6.4/Ex6_4.sce | 11 | ||||
-rw-r--r-- | 3808/CH6/EX6.5/Ex6_5.sce | 14 | ||||
-rw-r--r-- | 3808/CH6/EX6.6/Ex6_6.sce | 21 | ||||
-rw-r--r-- | 3808/CH6/EX6.7/Ex6_7.sce | 20 | ||||
-rw-r--r-- | 3808/CH6/EX6.8/Ex6_8.sce | 20 | ||||
-rw-r--r-- | 3808/CH6/EX6.9/Ex6_9.sce | 17 |
16 files changed, 339 insertions, 0 deletions
diff --git a/3808/CH6/EX6.1/Ex6_1.sce b/3808/CH6/EX6.1/Ex6_1.sce new file mode 100644 index 000000000..2afa6464b --- /dev/null +++ b/3808/CH6/EX6.1/Ex6_1.sce @@ -0,0 +1,13 @@ +//Chapter 06: Counting + +clc; +clear; + +n=2 //no of employees +r=12 //no of office rooms +sanchez=12 +patel=11 +sol=sanchez*patel + +//product rule +mprintf("Total no of ways to assign offices to these employees is %d",sol) diff --git a/3808/CH6/EX6.10/Ex6_10.sce b/3808/CH6/EX6.10/Ex6_10.sce new file mode 100644 index 000000000..7b4136221 --- /dev/null +++ b/3808/CH6/EX6.10/Ex6_10.sce @@ -0,0 +1,25 @@ +//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 + +num=input("Enter the number of elements:") +com=input("Enter the number of combinations:") +res=combination(num,com) +mprintf("The number of combinations are %d ",res) diff --git a/3808/CH6/EX6.11/Ex6_11.sce b/3808/CH6/EX6.11/Ex6_11.sce new file mode 100644 index 000000000..e16105aab --- /dev/null +++ b/3808/CH6/EX6.11/Ex6_11.sce @@ -0,0 +1,29 @@ +//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 + +//Part A Solution +num=input("Enter the number of cards in the deck(For standard deck n=52):") +com1=input("Enter the number of cards for poker hands determination:") +com2=input("Enter the number of cards to select no of ways:") +res1=combination(num,com1) +mprintf("The number of poker hands of %d cards that can be dealt are %d ",com1,res1) +res2=combination(num,com2) +mprintf("\nThe number of ways to select %d cards from a standard deck are %d ",com2,res1) diff --git a/3808/CH6/EX6.12/Ex6_12.sce b/3808/CH6/EX6.12/Ex6_12.sce new file mode 100644 index 000000000..72830762d --- /dev/null +++ b/3808/CH6/EX6.12/Ex6_12.sce @@ -0,0 +1,25 @@ +//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 + +num=input("Enter the total number of members in a team:") +com=input("Enter the number of players:") +res=combination(num,com) +mprintf("The number of combinations are %d ",res) diff --git a/3808/CH6/EX6.13/Ex6_13.sce b/3808/CH6/EX6.13/Ex6_13.sce new file mode 100644 index 000000000..c926eca40 --- /dev/null +++ b/3808/CH6/EX6.13/Ex6_13.sce @@ -0,0 +1,25 @@ +//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 + +num=input("Enter the number of astronauts:") +com=input("Enter the number of astronauts to be selected:") +res=combination(num,com) +mprintf("The number of combinations are %d ",res) 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) diff --git a/3808/CH6/EX6.15/Ex6_15.sce b/3808/CH6/EX6.15/Ex6_15.sce new file mode 100644 index 000000000..d9a115522 --- /dev/null +++ b/3808/CH6/EX6.15/Ex6_15.sce @@ -0,0 +1,32 @@ +//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 + +fac=1 +nc=52//no of cards in a standard deck +num1=input("Enter the number of cards to distribute:") +num2=input("Enter the number of players:") +for i=1:num2 + fac=fac*combination(nc,num1) + nc=nc-num1 +end + +mprintf("The total number of ways to deal %d players %d cards each is",num2,num1) +disp(fac) diff --git a/3808/CH6/EX6.16/Ex6_16.sce b/3808/CH6/EX6.16/Ex6_16.sce new file mode 100644 index 000000000..a9f3fe42e --- /dev/null +++ b/3808/CH6/EX6.16/Ex6_16.sce @@ -0,0 +1,29 @@ +//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 number of indistinguishable bins:") +num2=input("Enter the number of distinguishable bins:") + +//Using formula C(n+r-1,n-l) we obtain + +comb=combination(num2+num1-1,num2-1) + +mprintf("There are %d number of ways to place %d objects into %d distinguishable boxes",comb,num1,num2) diff --git a/3808/CH6/EX6.2/Ex6_2.sce b/3808/CH6/EX6.2/Ex6_2.sce new file mode 100644 index 000000000..407f66fa1 --- /dev/null +++ b/3808/CH6/EX6.2/Ex6_2.sce @@ -0,0 +1,11 @@ +//Chapter 06: Counting + +clc; +clear; + +letters=26 //Total no of letters in the english alphabet +post=100 //Total positive no.s not beyond 100 +sol=letters*post + +//number of chairs to be labelled with an alphabet and an integer using product rule +mprintf("Total number of chairs that can be labelled with an alphabet and an integer is %d",sol) diff --git a/3808/CH6/EX6.3/Ex6_3.sce b/3808/CH6/EX6.3/Ex6_3.sce new file mode 100644 index 000000000..42134de52 --- /dev/null +++ b/3808/CH6/EX6.3/Ex6_3.sce @@ -0,0 +1,11 @@ +//Chapter 06: Counting + +clc; +clear; + +mc=32 //total no of microcomputers +p=24 //total no of ports in each microcomputer +sol=mc*p + +//total number of different ports to a microcomputer in the center are found using product rule +mprintf("Total number of ports is %d",sol) diff --git a/3808/CH6/EX6.4/Ex6_4.sce b/3808/CH6/EX6.4/Ex6_4.sce new file mode 100644 index 000000000..6b057a4f0 --- /dev/null +++ b/3808/CH6/EX6.4/Ex6_4.sce @@ -0,0 +1,11 @@ +//Chapter 06: Counting + +clc; +clear; + +bits=2 //possible bits are either 0 or 1 +ns=7 //no of bits in the string (ie). length of the string +sol=bits**ns + +// 7 bits are capable of taking either 0 or 1 so by PRODUCT RULE +mprintf("Total different bit strings of length seven are %d",sol) diff --git a/3808/CH6/EX6.5/Ex6_5.sce b/3808/CH6/EX6.5/Ex6_5.sce new file mode 100644 index 000000000..576708e95 --- /dev/null +++ b/3808/CH6/EX6.5/Ex6_5.sce @@ -0,0 +1,14 @@ +//Chapter 06: Counting + +clc; +clear; + +letters=26 //no. of letters in english alphabet +no_of_letters=3 //number of letters +choices=10 //number of choices for each letter +result=1//in order to avoid junk values. Assigned it to 1. +for i=1:no_of_letters +result=result*letters*choices +end + +mprintf("The total number of choices are %d",result) diff --git a/3808/CH6/EX6.6/Ex6_6.sce b/3808/CH6/EX6.6/Ex6_6.sce new file mode 100644 index 000000000..25b0b648e --- /dev/null +++ b/3808/CH6/EX6.6/Ex6_6.sce @@ -0,0 +1,21 @@ +//Chapter 06: Counting + +clc; +clear; + +function res=permutation(n,r) //function definition +i=n +res=1 +l=(n-r)+1 +u=n +for i=l:u //computing the permutation +res=res*i +end +return res +endfunction + +a=permutation(5,3)//function call +b=permutation(5,5)//function call + +mprintf("The number of ways to select 3 students from a group of 5 students to line up for a picture is %d",a) +mprintf("\nThe number of ways to select 5 students from a group of 5 students to line up for a picture is %d",b) diff --git a/3808/CH6/EX6.7/Ex6_7.sce b/3808/CH6/EX6.7/Ex6_7.sce new file mode 100644 index 000000000..d1b2a36c2 --- /dev/null +++ b/3808/CH6/EX6.7/Ex6_7.sce @@ -0,0 +1,20 @@ +//Chapter 06: Counting + +clc; +clear; + +function res=permutation(n,r) //function definition +i=n +res=1 +l=(n-r)+1 +u=n +for i=l:u //computing the permutation +res=res*i +end +return res +endfunction + +num=input("Enter the number of people:") +perm=input("Enter the number of prizes:") +result=permutation(num,perm) +mprintf("The number of ways to decide the prize winners is %d ",result) diff --git a/3808/CH6/EX6.8/Ex6_8.sce b/3808/CH6/EX6.8/Ex6_8.sce new file mode 100644 index 000000000..f3d23d608 --- /dev/null +++ b/3808/CH6/EX6.8/Ex6_8.sce @@ -0,0 +1,20 @@ +//Chapter 06: Counting + +clc; +clear; + +function res=permutation(n,r) //function definition +i=n +res=1 +l=(n-r)+1 +u=n +for i=l:u +res=res*i +end +return res +endfunction + +num=input("Enter the number of runners:") +perm=input("Enter the number of prizes:") +result=permutation(num,perm) +mprintf("The number of ways to decide the prize winners is %d ",result) diff --git a/3808/CH6/EX6.9/Ex6_9.sce b/3808/CH6/EX6.9/Ex6_9.sce new file mode 100644 index 000000000..7ebf8aec9 --- /dev/null +++ b/3808/CH6/EX6.9/Ex6_9.sce @@ -0,0 +1,17 @@ +//Chapter 06: Counting + +clc; +clear; + +function res=citycal(n) //function definition +i=n +res=1 +for i=1:n-1 +res=res*i +end +return res +endfunction + +num=input("Enter the number of cities:") +result=citycal(num) +mprintf("The number of possible ways to decide the path is %d ",result) |