Which of the following lines should be added to complete the above code?
arr[num_of_dice][S]
arr[dice][sm]
arr[dice][S]
arr[S][dice]
Answer and explanation
The line arr[num_of_dice][S] completes the above code.
ObjectiveMcq
Print Protected
This page is protected for print. Use the website to view the content.
8 practice sets · Page 1 of 1
Which of the following lines should be added to complete the above code?
arr[num_of_dice][S]
arr[dice][sm]
arr[dice][S]
arr[S][dice]
The line arr[num_of_dice][S] completes the above code.
There are 10 dice having 5 faces. The faces are numbered from 1 to 5. What is the number of ways in which a sum of 4 can be achieved?
0
2
4
8
Since there are 10 dice and the minimum value each die can take is 1, the minimum possible sum is 10. Hence, a sum of 4 cannot be achieved.
There are n dice with f faces. The faces are numbered from 1 to f. What is the maximum possible sum that can be obtained when the n dice are rolled together?
1
f*f
n*n
n*f
The sum will be maximum when all the faces show a value f. The sum in this case will be n*f.
There are n dice with f faces. The faces are numbered from 1 to f. What is the minimum possible sum that can be obtained when the n dice are rolled together?
1
f
n
n*f
The sum will be minimum when all the faces show a value 1. The sum in this case will be n.
You have 2 dice each of them having 6 faces numbered from 1 to 6. What is the number of ways in which a sum of 11 can be achieved?
0
1
2
3
The sum of 11 can be achieved when the dice show {6, 5} or {5, 6}.
You have 3 dice each having 6 faces. What is the number of permutations that can be obtained when you roll the 3 dice together?
27
36
216
81
The total number of permutations that can be obtained is 6 * 6 * 6 = 216.
You have n dice each having f faces. What is the number of permutations that can be obtained when you roll the n dice together?
nnn...f times
fff...n times
nnn...n times
fff...f times
Each die can take f values and there are n dice. So, the total number of permutations is fff...n times.
You are given n dice each having f faces. You have to find the number of ways in which a sum of S can be achieved. This is the dice throw problem. Which of the following methods can be used to solve the dice throw problem?
Brute force
Recursion
Dynamic programming
Brute force, Recursion and Dynamic Programming
Brute force, Recursion and Dynamic Programming can be used to solve the dice throw problem.