Menu

[Solved]1 Following Correct Code Snippet Throwing Pair 12 Sided Dice Get Sum Numbers Two Dice 2 24 Q37206280

1.Which of the following is the correct code snippet forthrowing a pair of 12-sided dice to get a sum of the numbers on twodice between 2 and 24 with different probabilities

2 * (rand() % 11 + 2)

rand() % 23 + 2

(rand() % 12) + (rand() % 12)

(rand() % 12 + 1) + (rand() % 12 + 1)

2.What would be the correct replacement for the following if ()statement ?

if (0 > temperature > 212)

It is correct, no need to replace the statement.

if (0 > temperature && temperature > 212)

if (0 > temperature || temperature > 212)

if (0 > temperature and temperature > 212)

3.What, if anything, is syntactically wrong with the followingfunction definition?

int sign(int x) { if (x < 0) return -1; else if (x > 0) return 1; }

It should have a double argument, not an int.

If x == 0, neither return statement is executed.

The if() statement needs braces {}.

The code has no syntax errors.

4.What is calculated by the code snippet?

int n = 0;int x;while (cin >> x){ if (x > n) { n = x; }}

The average of the input values

The number of input values

The minimum value of all input values

The maximum value of all input values

Expert Answer


Answer to 1.Which of the following is the correct code snippet for throwing a pair of 12-sided dice to get a sum of the numbers on… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *