Program question

This is a discussion on Program question within the C++ Programming forums, part of the General Programming Boards category; Does any one have the program for C++ that the computer guesses the number that the user has? Please e ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    1

    Question Program question

    Does any one have the program for C++ that the computer guesses the number that the user has? Please e mail me the code if you got it.

    Thanks

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,659
    Nah.



    ITSA
    Socket Library!

  3. #3
    EnforcerGIS
    Guest

    Re: Program question

    Dude,

    That is pretty simple code to do yourself really....what are you wanting someone else to do your homework?

    I'll give you a hint...have the computer generate a random number, then have the user guess on the number. From there you can do stuff like say "Guess higher" or "Guess lower". Then finally when they guess right you can end the guesses.

    Other things to add on are print out how many guesses it took to get the right number, ask the user if they want to play again, have a setup option so you can have a selected range.

    1.) Guess between 1 - 10 (Easy)
    2.) Guess between 1 - 100 (Intermidiate)
    3.) Guess between 1 - 1000 (Hard)

  4. #4
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078

    Re: Re: Program question

    Originally posted by EnforcerGIS
    I'll give you a hint...have the computer generate a random number, then have the user guess on the number. From there you can do stuff like say "Guess higher" or "Guess lower". Then finally when they guess right you can end the guesses.
    To be best, don't start with a random number -- start with the maximum number / 2, then when thy say higher or lower give the midpoint between that number and the current extreme. keep doing that until you get the number. It's a binary search.

  5. #5
    I am he who is the man! Stan100's Avatar
    Join Date
    Sep 2002
    Posts
    361

    great topic name...

    wow, your post name really tells us about your problem.
    Stan The Man. Beatles fan

    When I was a child,
    I spoke as a child,
    I thought as a child,
    I reasoned as a child.
    When I became a man,
    I put childish ways behind me"
    (the holy bible, Paul, in his first letter to the Cor. 13:11)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question regarding a this C program
    By cnb in forum C Programming
    Replies: 10
    Last Post: 10-11-2008, 04:43 AM
  2. newb question: probs with this program
    By ajguerrero in forum C Programming
    Replies: 5
    Last Post: 04-19-2006, 08:04 AM
  3. Random Question Assign Program
    By mikeprogram in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2005, 09:04 PM
  4. Question type program for beginners
    By Kirdra in forum C++ Programming
    Replies: 7
    Last Post: 09-15-2002, 05:10 AM
  5. Replies: 8
    Last Post: 03-26-2002, 06:55 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21