Question
Code in C: I'm trying to write code for a pick up sticks game for an assignment. The user can only enter 1,2, or 3
Code in C:
I'm trying to write code for a pick up sticks game for an assignment. The user can only enter 1,2, or 3 sticks to pick from a pile. If two invalid numbers are entered in a row then the program is supposed to terminate. I'm having trouble figuring out how to get the program to accept only a 1,2, or 3. When I use the current code I have or try to use the variable I tied to scanf, the while loop considers any number entered as invalid. Even if a 1,2, or 3 is entered. What's a good way to write the code so it will compare the command line argument to either 1,2, or 3 and terminate after 2 incorrect tries in a row?
Here's the code I have:
#includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started