Important Notice:

Find the Largest Number in an Array

Find the Largest Number in an Array

5 views 1 min read

Find the Largest Number in an Array (ऐरे में सबसे बड़ी संख्या ज्ञात करना) :-

Question -

Write an algorithm and flowchart to find the largest number in an array.

किसी Array में सबसे बड़ी संख्या ज्ञात करने के लिए Algorithm और Flowchart लिखिए।

Example -

Input:

Array A = [25, 40, 18, 75, 50]

Output:

Largest Number = 75
 

Solution - Algorithm: Find the Largest Number in an Array

Step 1: Start.

Step 2: Input the number of elements N.

Step 3: Input the array elements.

Step 4: Set MAX = A[0].

Step 5: Set i = 1.

Step 6: If A[i] > MAX, then set MAX = A[i].

Step 7: Set i = i + 1.

Step 8: Repeat Steps 6 and 7 while i < N.

Step 9: Display MAX.

Step 10: Stop.

Logic / Working (कार्यप्रणाली)-

  • MAX = A[0]  सेट करें, अर्थात पहले Element को सबसे बड़ा मानें। — Set MAX = A[0], i.e., assume the first element is the largest.
  • i = 1             सेट करें, अर्थात दूसरे Element से तुलना शुरू करें। — Set i = 1, i.e., start comparing from the second element.
  • यदि A[i] > MAX हो, तो MAX = A[i] करें। — If A[i] > MAX, then set MAX = A[i].
  • i = i + 1 करें, अर्थात अगले Element पर जाएँ। — Set i = i + 1, i.e., move to the next element.
  • जब तक i < N हो, तुलना दोहराएँ। — Repeat the comparison while i < N.
  • अंत में MAX को Display करें, यही Array का सबसे बड़ा Element होगा। — Finally, display MAX, which is the largest element in the array.

Related Notes