Computer Science, asked by bhanu066, 7 months ago

Write a sub algorithm to find the largest element from the given array. illustrate using an example

Answers

Answered by athulyavincent
2

Explanation:

example: Input : art [ ] = { 10 ,20 ,4}

output: 20

example 2: Input: arr [ ] = { 20,10,20,40,100}

output: 100

hope it helps you

Answered by Agastya0606
1

Algorithm to find the largest element from array

step 1: Take input for the array elements.

step 2: Initialize large = arr[0]

step 3: Repeat from i = 2 to n

step 4: if(arr[i] > large)

step 5: large = arr[i]

step 6: Print the value of large.

Example:

firstly take the input.

suppose the array[] = {5,13,1} , so here , value of n is 3

int large = 5 // initialize first element of array.

now within the for loop, we have to check which one is largest between arr[i] and large.

The largest value in the array is 13.

Similar questions