Homework 7: First Loops

Wednesday, March 14, 2012     


[Up] [Previous Homework] [Next Homework]


Complete the following:

  1. Create a new file called hw07.c
  2. You are going to create a program that will ask the user to guess a number
  3. Create a program that has a "secret" number not displayed to the user
  4. The secret number can be defined in your program using #define as follows:
  5. #define SECRET 171
  6. Change 171 to your own number
  7. Ask the user to guess the number
  8. If the user guesses the right number, print "You got it right!" and exit
  9. If the user guesses too low, print "Too low" and let the user guess again
  10. If the user guesses too high, print "Too high" and let the user guess again
  11. 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"
  12. Create a script of you running your program (only once is required).
  13. Once you are done, use submit to submit two files, hw07.c and typescript

    linux3[1]% submit cs104_sheets hw07 hw07.c typescript