1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Drawing a flowchart

  1. Jul 20, 2011 #1
    1. The problem statement, all variables and given/known data
    I have just started learning C++ in my school. Teachers have started with teaching us to make flowcharts. My teacher gave us a question:-
    "Draw a flowchart to read three numbers from the user and print the larger one."

    2. Relevant equations



    3. The attempt at a solution
    Here's what i tried:-
    9r7ib6.jpg
    "T" for true and "F" for False.
    Please tell me if i am wrong somewhere and i am also stuck at the last step. I don't know how should i proceed from there?

    Thanks!! :smile:
     
  2. jcsd
  3. Jul 20, 2011 #2
    Hi!

    Yes, it looks correct. But if you want a proper flowchart you should have that final "False" going somewhere. I would suggest using the "Equal" option to be the recipient of that false arrow, and have it go to your "stop" block. A flowchart is your psuedo-code essentially, and a code with a loose "arrow" like that might not work or make sense. Covering all options, even if improbable, that your program could possibly go is the sign of clean and elegant programming and that starts with your flowchart.

    That being said, perhaps you could have this program loop and ask the user if they wish to try three more numbers? But that is purely aesthetic.

    Is your next step trying to code it?
     
  4. Jul 20, 2011 #3
    Thanks for your reply!! :smile:
    No, my next step isn't to code it. My teacher firstly wants us to build up the logic that how programming should be planned. :wink:
    How do i make the flowchart to make program loop?
     
  5. Jul 20, 2011 #4
    Adding that looping effect is pretty easy. So instead of going to your "stop" block, all of the arrows that are currently going to it would instead go to another decision box (like the ones you have determining the size of the numbers). This box would state something like "Repeat Process?" and the true would once more go to the first box of your flow chart and the false would then go to your "stop" box.

    Now as far as where you're going after this... I'm not sure. You're probably going to have to list a few more details or stipulations that your teacher gave other than "build up your logic." I would interpret it as the elegance of your code in that it is efficient and covers up all logical paths/decisions. For instance, if you were to take my suggestion from the other post you would eliminate an unnecessary decision box, thereby making the code's logic more efficient.

    So questions to ask yourself would be - Are there any additional decisions that your flowchart isn't covering that your inputted numbers could provide? Are there any techniques or mathematical tricks that would allow you to determine the largest number faster (so less decision boxes... meaning less code) then what you have right now?
     
  6. Jul 20, 2011 #5
    I think i would add that loop effect. Thanks. :smile:

    I think i should not get into mathematical tricks for this question since it has been only two days my teacher has started this. And i think i would remove one of the decision box i.e. "if a==b". I think my flowchart is covering all the decisions. Do you think are there any more?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Drawing a flowchart
  1. Logarithm flowchart (Replies: 3)

  2. Flowcharts Help (Replies: 3)

  3. Drawing circuits (Replies: 1)

  4. Technical drawings (Replies: 2)

Loading...