Check out example codes for "Write a program to find max and min element in an array. User must input 5 elements in the array.". It will help you in understanding the concepts better.

Code Example 1

#include <stdio.h>
 #include <conio.h>
 
 

    {
        scanf("%d",&a[i]);
    }int main()
{
    int a[1000],i,n,min,max;
   
    printf("Enter size of the array : ");
    scanf("%d",&n);
 
    printf("Enter elements in array : ");
    for(i=0; i<n; i++)
 
    min=max=a[0];
    for(i=1; i<n; i++)
    {
         if(min>a[i])
		  min=a[i];   
		   if(max<a[i])
		    max=a[i];       
    }
     printf("minimum of array is : %d",min);
          printf("\nmaximum of array is : %d",max);
 
 
    return 0;
}

Learn ReactJs, React Native from akashmittal.com