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