I am very new to programming and am in a class that has quite the frustrating instructor. He gives very simple examples then asks very complex questions. Complex to me atleast. Anyone who could shed some light on these would be greatly appreciated.
Write a program to play a number guessing game with the user. The program should keep asking for a number between 1 and 100 in the input, comparing it with a stored value (e.g. "#define MY_NUMBER 72") and informing the user about the outcome, until the correct guess is made. Below is an example of a sample run, with user input in boldface.
Welcome to the game of Guess It!
I will choose a number between 1 and 100.
You will try to guess that number. If you guess wrong,
I will tell you if you guessed too high or too low.
Your guess: 67
Your guess: 89
Your guess: 0
Illegal guess. Your guess must be between 1 and 100.
Your guess: 72
*** CORRECT ***
Your score is 3.
(This is a modified Exercise 2.11 from the text. Note that there are some differences between the textbook version and this one - here the program should exit once the correct guess is made, it should not restrict the user to up to 6 guesses, and it should also keep track of the user's score, i.e. the number of guesses made until CORRECT, not counting illegal attempts.)
Internals: Your program should use a while loop in order to assure the continuing execution until the correct guess is made. Checking whether the user's input was correct should be done by a separate function (receiving the number provided in the input as its parameter, and returning 1 or 0, depending on whether the guess was correct or not), and checking whether the guess was correct should be done by another function (receiving the guess and the target as its parameters, and returning -1 for TOO_LOW, 0 for CORRECT and +1 for TOO_HIGH - all 3 values should be defined as pre-processor constants). The main block should implement the while loop, prompt the user for the input, check it and display the result.