Hi, can I get some help with this problem. Make sure to have one function displa
ID: 3692765 • Letter: H
Question
Hi, can I get some help with this problem. Make sure to have one function displaying the menu (scissors, paper, or rock), reading the choice, validating it and rereading if needed, and then returning the valid choice as a number 1-3. Make sure to have another function to which you send what the user selected and what computer generated, and the function will declare the winner printing the result. Make sure to use srand() Also put a loop for the program to keep working on multiple games until the user enters a quit choice on the menu (the same menu where the choice is entered). Thank you!
Explanation / Answer
int select()
{
char str[10];
printf("enter your choice");
scanf("%s",&str);
if(strcmp(str,scissors))
return 1;
if(strcmp(paper,str))
return 2;
if(strcmp(str,rock))
return 3;
return 0;
}
void winner_decide()
{
int i;
while((i=select())!=0)
{
int random_number=srand(1,3);
if(i==random_number)
printf("user wins");
else
printf("user loose");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.