Drawing a Flowchart: Read 3 Numbers & Print Larger One

  • Thread starter Saitama
  • Start date
  • Tags
    Drawing
In summary, the conversation is about a student learning C++ and creating a flowchart to read three numbers from the user and print the larger one. The student receives feedback on their flowchart and discusses the possibility of adding a looping effect and improving the logic. They also consider any additional decisions that the flowchart may not cover and ways to make the code more efficient. The student decides to remove one of the decision boxes and concludes that their flowchart is covering all necessary decisions.
  • #1
Saitama
4,243
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
  • #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?
 
  • #3
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?
 
  • #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?
 
  • #5
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?
 

1. What is a flowchart?

A flowchart is a visual representation of a process or algorithm. It uses symbols and arrows to show the flow of steps and decisions within the process.

2. Why is a flowchart useful?

A flowchart is useful because it allows for a clear and organized representation of a process, making it easier to understand and follow. It also helps identify errors or inefficiencies in the process.

3. How do you draw a flowchart?

To draw a flowchart, you first need to identify the steps and decisions involved in the process. Then, use symbols and arrows to represent each step and decision, making sure to follow the correct flow of the process. It is also important to label each step and decision for clarity.

4. What is the purpose of the "Read 3 Numbers & Print Larger One" flowchart?

The purpose of this flowchart is to show the process of reading three numbers and determining the largest number out of the three.

5. How do you determine the larger number in the flowchart?

In the flowchart, the numbers will be compared using decision symbols (usually represented by diamonds). The larger number will be determined by following the correct flow of the arrows and making the appropriate comparisons between the numbers.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
27
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
2
Replies
69
Views
20K
  • Biology and Chemistry Homework Help
Replies
1
Views
2K
  • Programming and Computer Science
Replies
22
Views
731
  • DIY Projects
Replies
8
Views
201
  • STEM Academic Advising
Replies
13
Views
828
  • Engineering and Comp Sci Homework Help
Replies
6
Views
1K
  • Special and General Relativity
Replies
15
Views
447
  • Science and Math Textbooks
Replies
17
Views
2K
Back
Top