Write an algorithm to find the maximum element in the given array.
Step 1 : [Assume first element is the largest ] large = A [ 0 ]
Step 2 : POS = 0.
Step 3 : [Find the largest element in the array and its position] For I = 1 to N – 1
Step 4 : If ( A [ I ] > large ) Then
Step 5 : large = A [ I ]
Step 6 : POS = 1
[ End if ]
[ End of step 3 for loop ]
Step 7: [ Print the largest and its position] Print “ Largest = “ , large , “ position = “ , POS.
Step 8: Exit
Thanks
Mukesh Rajput
Post A Comment:
0 comments: