Question: Write the following program in C: int A[5]; srand( 4 ); for ( k = 0; k < 3; ++k ) A[k] = roll(6); for
Write the following program in C:
int A[5];
srand( 4 );
for ( k = 0; k < 3; ++k )
A[k] = roll(6);
for ( k = 0; k < 3; ++k )
printf("%d ", A[k]);
Output will be:
2
6
5
Now, roll a 10-sided dice 50 times
These do not have to be functions. But you are required to complete each in separate loops rather than all at once
Print out the first 3 values
Find the sum of all 50 values
How many 7s are rolled
How many times are 2 consecutive rolled numbers the same?
Ex: 5 7 10 10 5 here it happens 1 time
Make sure you stay within the bounds of the array
Function description make sure you have this function:
int roll( int )
Purpose: roll a dice, return the value
Params: how sides on the dice
If # of sides is outside 1 to 50 range, return 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
