Homework 7: First Loops
Wednesday, March 14, 2012[Up] [Previous Homework] [Next Homework]
Complete the following:
- Create a new file called hw07.c
- You are going to create a program that will ask the user to guess a number
- Create a program that has a "secret" number not displayed to the user
- The secret number can be defined in your program using #define as follows:
- #define SECRET 171
- Change 171 to your own number
- Ask the user to guess the number
- If the user guesses the right number, print "You got it right!" and exit
- If the user guesses too low, print "Too low" and let the user guess again
- If the user guesses too high, print "Too high" and let the user guess again
- EXTRA CREDIT: Add code to limit the number of attempts that the user can make. If the user tries too many times, print "You failed, the number was xxx"
- Create a script of you running your program (only once is required).
- Once you are done, use submit to submit two files, hw07.c and typescript
linux3[1]% submit cs104_sheets hw07 hw07.c typescript