Draw a flowchart to find and display the largest of three numbers entered by the user. Assume that the numbers are distinct and positive.
Answer:
Answer by student
Detailed answer by teachoo
-lock-
- To draw the flowchart, we need to use the following symbols: start/end, input/output, process and decision. A start/end symbol indicates the beginning or end of the flowchart. An input/output symbol indicates the input or output of data. A process symbol indicates an operation or calculation. A decision symbol indicates a conditional statement or a comparison.
- We first draw a start symbol and label it as “ Start ”.
- Then we draw an input symbol and label it as “ Read A, B, C ”. This means that we ask the user to enter three numbers and store them in variables A, B and C.
- Next, we draw a decision symbol and label it as “ Is A > B? ”. This means that we compare the values of A and B and check if A is greater than B. If yes, we follow the true branch. If no, we follow the false branch.
- On the true branch, we draw another decision symbol and label it as “ Is A > C? ”. This means that we compare the values of A and C and check if A is greater than C. If yes, we follow the true branch. If no, we follow the false branch.
- On the true branch of the second decision symbol, we draw an output symbol and label it as “ Print A ”. This means that we display the value of A as the largest number.
- On the false branch of the second decision symbol, we draw an output symbol and label it as “ Print C ”. This means that we display the value of C as the largest number.
- On the false branch of the first decision symbol, we draw another decision symbol and label it as “ Is B > C? ”. This means that we compare the values of B and C and check if B is greater than C. If yes, we follow the true branch. If no, we follow the false branch.
- On the true branch of the third decision symbol, we draw an output symbol and label it as “ Print B ”. This means that we display the value of b as the largest number.
- On the false branch of the third decision symbol, we draw an output symbol and label it as “ Print C ”. This means that we display the value of c as the largest number.
- Finally, we draw an end symbol and label it as “ Stop ”.
So, the flowchart is:
-endlock-