Recursive Programs to find Minimum and Maximum elements of array | Recursive C # program to find maximum ; function to return maximum element using recursion ; if size = 0 means whole array has been traversed ; Driver code ; Function calling
using System ; class GFG { public static int findMaxRec ( int [ ] A , int n ) { if ( n == 1 ) return A [ 0 ] ; return Math . Max ( A [ n - 1 ] , findMaxRec ( A , n - 1 ) ) ; } static public void Main ( ) { int [ ] A = { 1 , 4 , 45 , 6 , - 50 , 10 , 2 } ; int n = A . Length ; Console . WriteLine ( findMaxRec ( A , n ) ) ; } }