# Program to find the largest element in an array by recursion

## Program to find the largest element in an array by recursion:-

Given an array of elements , write a Program to find the largest element in an array by recursion .

Sample input:-

a[]={3,4,1,43,5,11}

Sample output:-

Largest element in the array is 43

## Program to find the largest element in an array by recursion:-

The objective of this code is to find the largest element in an given array . So we traverse the array recursively from the end of the array to the starting .

C Code:-

```#include<stdio.h>

// function for calculate max between
// two element
int max(int a,int b)
{
return a>b?a:b;
}

// Recursive function for finding the Largest element
int Largest(int a[],int n)
{
if(n==1)
return a[0];
return max(a[n-1],Largest(a,n-1));
}
int main()
{
int a[]={3,4,1,43,5,11};
int n=sizeof(a)/sizeof(a[0]) ;
printf("Largest element in the array is %d",Largest(a,n));
return 0;
}```

Output:-

`Largest element in the array is 43`