Help With Flowchart (Non-Code Issue)
Hello everyone and Good Morning! ~o) In learning about Counters and Accumulators, I have been given the task to create a flowchart that does the following:
"Ask the user for a positive, whole number > 0, call it x. Output all the numbers from 1 up to x."
I have a few flowcharts written out that don't quite do what I want them to do when I desk-check them. I could use a little help/ a nudge in the right direction (As this forum is filled with people who tend to do just that, and only that *no offense*)
A flowchart I have created goes as follows in descending order:
(Counter) outX = outX + 0
Output - "Enter positive whole number"
Input - x
Decision (outX = x)?
-No- (x = x -1) (outX = outX + 1) >>>>>>>> Output " outX " >>>> Loop back to decision
-Yes- Output "outX, x"
I know this is very basic and I am missing something, but I don't quite know what. Any help or advice would be greatly appreciated. :)>-
Re: Help With Flowchart (Non-Code Issue)
A few questions:
1. Why have you initialized your counter to outX + 0? Why not just 0?
2. I don't know if it would be part of your requirements, but in a real-life situation, you would want to varify that the user did in fact give you a number > 0. Just because you tell a user to do something, doesn't mean they actually will.
3. Why are you decrementing x in your loop? If you subtract x by 1 and add outX by 1, you are technically advancing the counter by 2 since you do an equals check with outX and x (and, if x is odd, you will pass right by the value since they will never equal each other).