Drawing a Flowchart: Read 3 Numbers & Print Larger One

  • Thread starter Thread starter Saitama
  • Start date Start date
  • Tags Tags
    Drawing
Click For Summary
The discussion focuses on creating a flowchart to read three numbers and print the largest one as part of a C++ homework assignment. Participants emphasize the importance of ensuring all logical paths are covered in the flowchart, including handling equal numbers and implementing a loop for repeated input. Suggestions include adding a decision box for repeating the process and refining the flowchart to eliminate unnecessary decision points for efficiency. The student expresses a desire to keep the flowchart simple, avoiding complex mathematical tricks at this early stage of learning. Overall, the conversation highlights the significance of clear logic and structure in programming flowcharts.
Saitama
Messages
4,244
Reaction score
93

Homework Statement


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."

Homework Equations





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:
 
Physics news on Phys.org
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?
 
Ecthelion said:
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?

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?
 
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?
 
Ecthelion said:
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.

I think i would add that loop effect. Thanks. :smile:

Ecthelion said:
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?

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?
 

Similar threads

  • · Replies 27 ·
Replies
27
Views
5K
  • · Replies 69 ·
3
Replies
69
Views
23K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 28 ·
Replies
28
Views
4K
Replies
4
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
33
Views
4K
  • · Replies 8 ·
Replies
8
Views
6K
  • · Replies 4 ·
Replies
4
Views
2K