Skip to main content

Algorithm and flowchart for largest

Short answer

Read N, set largest to the first number, then for each remaining number read and update largest if the number is larger; finally print largest.

Develop an algorithm and draw a flowchart to find the largest of N numbers.

Algorithm

  1. Start
  2. Read N (count of numbers)
  3. Read the first number X and set L = X
  4. Set I = 2
  5. While I <= N, repeat steps 6 to 8
  6. Read X
  7. If X > L, set L = X
  8. Set I = I + 1
  9. Print L as the largest number
  10. Stop

Flowchart

        ( Start )
            |
       / Read N /
            |
       / Read X /
            |
        [ L = X ]
        [ I = 2 ]
            |
     +----->|
     |      v
     |   < I <= N ? >--No--> / Print L / --> ( Stop )
     |      | Yes
     |  / Read X /
     |      |
     |  < X > L ? >--No---+
     |      | Yes         |
     |  [ L = X ]         |
     |      |             |
     |      +<------------+
     |      |
     |  [ I = I + 1 ]
     +------+

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Programming chapter 2 questions →