Thread: playing dice, or guessing a number games program

  1. #1
    Registered User
    Join Date
    Jan 2013

    playing dice, or guessing a number games program

    , asking the user to choose between the two games,or exit. It is up to you to design this prompt.
    Each game must be programmed in its own function, not in main()! main will call the games’functions.
    At the end of each game, the user is returned to the
    1. The user is asked to pick a number between 2 and 12.
    2. The computer rolls two dice, using random variables, and adds up the score on each die.
      Since each die can score from 1 to 6, the total score can be from 2 to 12.
    3. If the roll matches the user’s picked number, the user wins; otherwise, the user loses.
    4. The computer informs the user of the result (win or loss), and this game ends.

    [COLOR=rgb(0.000000%, 0.000000%, 100.000000%)]Guess a number:[/COLOR]

    1. The computer randomly selects a number between 0 and 100.
    2. The computer asks the user to guess the number.
    3. The computer informs the user if the user’s guess is too high, too low, or right on. In the latter
      case, the user wins and we jump to step 4. Otherwise, we repeat from step 2 and the user will
      guess again.
    4. In this step the user has won. The computer tells the user how many tries it took for the user
      to guess it right, and this game ends.

      I already started something and this is what i have...I'm not asking you to do it, I want to know if I'm on the right track and if I've already made some mistakes, please correct me.
    Attached Files Attached Files

  2. #2
    Stoned Witch Barney McGrew's Avatar
    Join Date
    Oct 2012
    1. “Void” is not a C type. You probably want “void”.
    2. Neither “prinf” nor “print” are defined anywhere in your program. You probably want “printf”.
    3. printf doesn't terminate its output with a newline character ('\n'), so you might consider appending one to the end of your format strings, or alternatively, use puts.
    4. Using the value stored in choice has undefined behaviour if scanf returns 0 or EOF, so handle the cases where it returns those values appropriately.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Playing C++ games
    By gord360 in forum C++ Programming
    Replies: 4
    Last Post: 06-12-2009, 02:56 PM
  2. what games are you playing currently?
    By FloatingPoint in forum A Brief History of
    Replies: 55
    Last Post: 07-08-2003, 08:40 PM
  3. Playing C++ games online?
    By Stan100 in forum Game Programming
    Replies: 27
    Last Post: 06-16-2003, 03:26 PM
  4. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 05:00 PM
  5. making money and playing games...
    By Aran in forum A Brief History of
    Replies: 4
    Last Post: 09-10-2001, 07:13 PM

Tags for this Thread