Thread: *gulp*

  1. #1
    Student kahli_mist's Avatar
    Join Date
    Nov 2005
    Location
    Preston, UK
    Posts
    10

    *gulp*

    hello again!

    another silly problem ... i need to ask the user to enter a number. Checks to see whether the number is between 1 and 5 inclusive. If the number is valid then the function returns the number. If the number is invalid then the user is asked to re-enter a number.

    simple enough, but i'm lost. i need to use a do while loop... right?

    --

    ... you know when u leave everything to the last minute and then think, "gee, i wish i hadn't left everything till the last minute"
    What sweet nanny goat a go ru'n him belly...

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    loop:
        prompt for number
        check number
        if number ok
            return number
    goto loop; /* ;) */
    You just need to break your program up into tiny steps. Then break each step into another step. Repeat that until you have the simplest steps possible. Turn that into code. If you're going to play programmer, you have to actually think. It helps too, if the things you're thinking about actually relate to the task at hand.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Code:
    do
       prompt for number
       get num
    while(num < lowbound || num > uppbound)
     
    return number
    Last edited by indigo0086; 07-27-2006 at 07:11 AM.

Popular pages Recent additions subscribe to a feed