Q17.Write a code to find largest element in an array.

Solution :- In this program, we will find the largest/Maximum value element in an array.

For Example :-
input : arr[]={ 2, 5, 3, 6, 4 }
output : 6

So as we can see that the largest element in arr[] = { 2, 5, 3, 6, 4 } is 6 so the output is 6.

Algorithm for Array Largest Number

START
Step 1 → Take an array Arr and define its values
Step 2 → Declare one variable (VAR) and assign 1st element of array to it
Step 3 → Loop for each value of Arr Repeat Step 4
Step 4 → If Arr[I] > VAR, Assign Arr[I] to VAR
Step 5 → After loop finishes, Display VAR which holds the largest element of array
STOP

Code for Array Largest Number

Output

Largest element in an Array is =6

Recommended Programs
Program to find factorial of a number
Program to count number of digits in a number