Drawing a Flowchart: Read 3 Numbers & Print Larger One

  • Thread starter Thread starter Saitama
  • Start date Start date
  • Tags Tags
    Drawing
Click For Summary

Discussion Overview

The discussion revolves around creating a flowchart for a C++ program that reads three numbers from the user and prints the largest one. Participants explore the logic and structure of flowcharts, focusing on decision-making processes and the inclusion of loops.

Discussion Character

  • Homework-related
  • Exploratory
  • Technical explanation

Main Points Raised

  • One participant shares their initial flowchart attempt and expresses uncertainty about the final steps.
  • Another participant suggests that the flowchart should include a decision for the "Equal" case to ensure all logical paths are covered.
  • There is a proposal to add a loop that allows the user to input three more numbers after the initial comparison.
  • A later reply discusses how to implement the looping effect by redirecting arrows to a new decision box asking "Repeat Process?"
  • Participants question whether additional decisions or mathematical techniques could simplify the flowchart and improve efficiency.
  • One participant expresses hesitation about introducing advanced mathematical tricks at this early stage of learning.
  • There is a consideration to remove a decision box regarding equality to streamline the flowchart.

Areas of Agreement / Disagreement

Participants generally agree on the importance of covering all logical paths in the flowchart, but there are differing opinions on whether to include certain decision boxes and techniques. The discussion remains unresolved regarding the optimal structure of the flowchart.

Contextual Notes

Participants mention the need for clarity in flowchart design and the importance of covering all possible outcomes, but specific assumptions and requirements from the teacher are not fully detailed.

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
9
Views
9K
Replies
4
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
33
Views
5K
  • · Replies 8 ·
Replies
8
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K