2079 4

BIT102 ยท 2079 ยท 5 marks

What do you mean by flowchart? Draw a Flowchart to find the largest among three numbers entered by user.

What do you mean by flowchart? Draw a Flowchart to find the largest among three numbers entered by user. [5]

C ProgrammingChapter 4: Control StructuresFlowchart design

Quick answer

A flowchart is a diagrammatic or pictorial representation of an algorithm or a step-by-step solution to a given problem. It uses standard geometric symbols connected by arrows (flow lines) to show the sequence of steps, decisions, and operations required to solve a problem.

Flowchart

Definition

Common Flowchart Symbols

SymbolShapePurpose
TerminalOval / Rounded RectangleStart / Stop
Input/OutputParallelogramRead / Print data
ProcessRectangleArithmetic / Assignment operations
DecisionDiamondYes/No or True/False condition
Flow LinesArrowsDirection of flow

Flowchart to Find the Largest Among Three Numbers

Problem: Read three numbers A, B, and C from the user and find the largest among them.

        +----------+
        |  START   |
        +----------+
             |
             v
   +------------------+
   |  Read A, B, C    |
   +------------------+
             |
             v
       +------------+
       |   Is A > B? |
       +------------+
       /             \
     YES              NO
      |                |
      v                v
  +--------+       +--------+
  |Is A > C?|      |Is B > C?|
  +--------+       +--------+
  /        \       /        \
YES         NO   YES         NO
 |           |    |           |
 v           v    v           v
+---+      +---+ +---+      +---+
| A |      | C | | B |      | C |
|is |      |is | |is |      |is |
|Lar|      |Lar| |Lar|      |Lar|
|gest      |gest |gest      |gest
+---+      +---+ +---+      +---+
  \           \    /           /
   \           \  /           /
    \           \/           /
     \     +----------+     /
      \    |  Print   |    /
       +-->| Largest  |<--+
           +----------+
                |
                v
           +--------+
           |  STOP  |
           +--------+

Clean Step-by-Step Logic

START
  |
  Read A, B, C
  |
  Is A > B?
  โ”œโ”€โ”€ YES --> Is A > C?
  โ”‚           โ”œโ”€โ”€ YES --> Print "A is Largest"
  โ”‚           โ””โ”€โ”€ NO  --> Print "C is Largest"
  |
  โ””โ”€โ”€ NO  --> Is B > C?
              โ”œโ”€โ”€ YES --> Print "B is Largest"
              โ””โ”€โ”€ NO  --> Print "C is Largest"
  |
STOP

Example Trace

ABCA > B?Next CheckResult
1058YESA > C? (10>8) YESA = 10 is Largest
396NOB > C? (9>6) YESB = 9 is Largest
4611NOB > C? (6>11) NOC = 11 is Largest

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.