Results 1 to 5 of 5

Thread: simple C++ program

  1. #1
    Banned
    Join Date
    May 2005
    Posts
    12

    simple C++ program

    I have just started C++ and ran into a question that i am trying to figure out
    Write a fragment of code to display the middle value in a unordered set of three values. After displaying the result ask if the user wants to repeat the process. EX. 10 30 12, 12 would be shown.
    I need to use a while loop, but beyond that i have confused myself so i was hoping i could get some help

  2. #2
    Jaded Network Admin nebulus200's Avatar
    Join Date
    Jun 2002
    Posts
    1,356
    Sounds to be like you need to work on your algorithm a bit first...its always helpful to a person new to coding to layout exactly how they are going to solve a problem before trying to jump in and code it (so that you are focused on solving the problem first and then how to code it second and not mixing the two).

    So for example,

    1. Ask for three values
    2. Print 2nd value
    3. Goto step 1

    Then you look at your simple steps and ask yourself, how would I ask for the three values ? How would I print the 2nd one...how would I go back to the first step ? Congrats, you then have your code fragment...
    There is only one constant, one universal, it is the only real truth: causality. Action. Reaction. Cause and effect...There is no escape from it, we are forever slaves to it. Our only hope, our only peace is to understand it, to understand the 'why'. 'Why' is what separates us from them, you from me. 'Why' is the only real social power, without it you are powerless.

    (Merovingian - Matrix Reloaded)

  3. #3
    Banned
    Join Date
    May 2005
    Posts
    12
    thank you, after following that i was able to break it down into easier steps.

  4. #4
    () \/V |\| 3 |) |3\/ |\|3G47|\/3
    Join Date
    Sep 2002
    Posts
    744
    Also, if you can get into the habit of using pseudocode it may help you figure things out more easily. Pseudocode is just writing out your algorithm in english but in a way that transfers easily into code.

    Go Finland!
    Deviant Gallery

  5. #5
    Banned
    Join Date
    May 2005
    Posts
    12
    yeah i ended up just writing down what i needed on a scrap peice of paper, which i then turned into code...much easier

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •