Question: // Question 2: ComputerPick int computerPick() { int computer_pick = ROCK; char you, computer_pick, result; // QUESTION 2: replace the below statement so that computer
// Question 2: ComputerPick
int computerPick()
{
int computer_pick = ROCK;
char you, computer_pick, result;
// QUESTION 2: replace the below statement so that computer // picks 0, 1 or 2 randomly. you will need to use:
// 1) rand() and
// 2) the modulus operator '%' //
// man rand to see how to use rand (use the man pages) srand(time (NULL)); n = (rand () % 2);
// computer always picks rock here.
if (n = 0) computer_pick = '0';
else if (n = 1) computer_pick = '1';
else computer_pick = '2';
return computer_pick;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
