Question: C programming question The game of rock-paper-scissors was expanded so that it now includes rock-paperscissors-lizard-spock. The expansion was created by Sam Kass and Karen Bryla
C programming question
The game of rock-paper-scissors was expanded so that it now includes rock-paperscissors-lizard-spock. The expansion was created by Sam Kass and Karen Bryla and made famous on the Big Bang Theory. See http://bigbangtheory.wikia.com/wiki/Rock_Paper_Scissors_Lizard_Spock for the game rules. This program asks the user for the number of games to play, then simulates playing that number of games by repeatedly generating two random numbers (0=rock, 1=paper, 2=scissors, 3=lizard, and 4=spock) and then determining the winner. The main program, shown below, counts the number of times each player won and then print the results.
#include#include int getNumGames(void); int findWinner(int, int); void printResults(int, int, int, int); int main(void) { srand(0); int games, p1, p2, ans, ties=0, p1wins=0, p2wins=0; games = getNumGames(); for (int a=0; a
You must use at least three functions in your program to accomplish the three tasks shown below
int getNumGames(void); // get number of games to play
o Prompt the user for the number of games to play, read that number, return it
int findWinner(int, int); // determine a single game winner
o Returns a 0 for a tie, 1 if player 1 won that game, and a 2 if player 2 won that game
o The two arguments passed to the function are player 1s move (0-4) and player 2s move (0-4)
void printResults(int, int, int, int); // print the final results
o Prints the results after playing the specified number of games
o The four arguments passed are number of games, ties, player 1 wins, and player 2 wins
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
