class15QuestionsOfTheDay

Class 15
questions of the day
g = rand();
printf("%d", g);
What is the output? Circle all possible:
a) 2
b) -4
c) 5.5
d) 10000
g = rand()%8;
printf("%d", g);
What is the output? Circle all possible:
a) 2
b) 0
c) 50
d) 7
e) 8
g = 10 + rand()%8;
printf("%d", g);
What is the output? Circle all possible:
a) 2
b) 10
c) 15
d) 17
e) 18
g = a + rand()%b;
I want random numbers in the range 0 to 20
inclusive. What should a and b be?
g = a + rand()%b;
I want random numbers in the range 15 to 35
inclusive. What should a and b be?
g = a + rand()%b;
I want random numbers in the range -10 to 10
inclusive. What should a and b be?
Write a function to simulate rolling
one die.
Is this a good function for simulating
rolling 2 dice?
int roll2Dice()
{ int ans;
ans = 2 + rand() % 11;
return ans; }
In main:
int player[30];
A function:
/*find the index of the highest value
in list */
int findWinner(int list[]);
How would you call the function to find the index of
the winner?
a) winner = findWinner(int player[30]);
b) winner = findWinner(player[30]);
c) winner = findWinner(player[]);
d) winner = findWinner(player);