Question: How would I code this in C programming? NOT C++ Just C programming. Also, if possible, I would appreciate a screenshot of the code with

How would I code this in C programming? NOT C++ Just C programming. Also, if possible, I would appreciate a screenshot of the code with how it looks compiled to make things easier. I just need to the last 5 steps and provided the code for the 1st step. Thank you.

How would I code this in C programming? NOT C++ Just C

#include

#include

#include

#include

int ComputerMove(){

srand(time(NULL));

int randNum = (rand() % 3) + 1;

return randNum;

}

int UserMove(){

int num1;

scanf("%d",&num1);

return num1;

}

int main(){

int computerMove;

computerMove=ComputerMove();

printf("Computer Chose %d ",ComputerMove());

printf("User Chose %d ",UserMove());

int userMove;

userMove=UserMove();

//printf("%d ",userMove);

//printf("%d ",computerMove);

printf("computer chose ");

if(computerMove==1)

{

printf("Rock! ");

}

else if(computerMove==2)

{

printf("Paper! ");

}

else if(computerMove==3)

{

printf("Scissor! ");

}

else printf("Tie!");

//{

if ((userMove==1)&&(computerMove==1))

{

printf(" Tie!");

}

else if ((userMove==1)&&(computerMove==2))

{ printf(" Computer Wins!");

}

else if ((userMove==1)&&(computerMove==3))

{ printf(" User Wins!");

}

else if((userMove==2)&&(computerMove==1))

{ printf(" User Wins!");

}

else if((userMove==2)&&(computerMove==2))

{ printf(" Tie!");

}

else if((userMove==2)&&(computerMove==3))

{ printf(" Computer Wins!");

}

else if((userMove==3)&&(computerMove==1))

{ printf(" Computer Wins!");

}

else if((userMove==3)&&(computerMove==2))

{ printf(" User Wins!");

}

else if((userMove==3)&&(computerMove==3))

{ printf(" Tie!");

}

else

{ printf("You have select an invalid selection.");

}

}

Goals The goals for you to accomplish during class today are as follows: 1. Practice modular design! Write a function that plays rock, paper, or scissors with the user Start with the code you wrote that provides a ComputerMove function that picks the Rock, Paper, Scissors move randomly for the computer player, and a UserMove function that asks the user for their move and returns their selection Move the two function calls and the winner decision logic into a self-contained function called RockPaperScissors which plays one round of the game and returns the winner (0-tie, 1 user won, 2 computer won In your main(), call the RockPaperScissors function to play one round If the players tied, call the RockPaperScissors function again to play again Repeat until someone wins Make sure your code compiles and runs

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!