Program:

#include<stdio.h>
int main()
{
    int a[20],i,n,large,small;
    printf("Enter the Number of elements:");
    scanf("%d",&n);
    printf("Enter the %d Elements in the Array:",n);
 
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    
    large=small=a[0];    //large=a[0]  small=a[0]
    for(i=1;i<n;i++)
    {
        if(a[i]>large)
            large=a[i];
        if(a[i]<small)
            small=a[i];
    }
    
    printf("\n\t-->> The largest element is %d",large);
    printf("\n\t-->> The smallest element is %d\n",small);
 
    return 0;
}

Expected O/P:

Enter the Number of elements:5
Enter the 5 Elements in the Array:20
23
24
20
65

-->> The largest element is 65
-->> The smallest element is 20