You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
574 B
C

#include<stdio.h>
int getmax(int []);
int size;
int main()
{
int arr[100],max,i;
printf("Enter the size of the array: ");
scanf("%d",&size);
printf("Enter %d elements of array: ", size);
for(i=0; i<size; i++)
scanf("%d",&arr[i]);
max=getmax(arr);
printf("Largest element of array is: %d",max);
return 0;
}
int getmax(int arr[])
{
static int i=0,max =0;
if(i < size)
{
if(max<arr[i])
max=arr[i];
i++;
getmax(arr);
}
return max;
}