Program to accept ‘n’ numbers from user, store these numbers into anarray. Find out Maximum and Minimum number from an Array(using function).


#include<stdio.h>
#include<conio.h>
void minmax(int a[5],int n);
void main()
 {
 int a[5];
 int i,n,max,min;
 clrscr();
 printf("\n entre the limit of array");
 scanf("\n %d",&n);
 printf("\n enter the array element");
 for(i=0;i<n;i++)
  {
  scanf("\n %d",&a[i]);
  }

  minmax(a,n);
  getch();
  }
  void minmax(int a1[5],int n1)
  {
  int max,min,i;
  max=a1[0],min=a1[0];
 for(i=1;i<n1;i++)
  {
  if(a1[i]>max)
   {
   max=a1[i];
   }
   if(a1[i]<min)
   {
   min=a1[i];
   }

  }
  printf("\n the largest element is %d",max);
  printf("\n the smallest element is %d",min);
 }
/* output

 entre the limit of array5

. enter the array element 67 56 1 45 234

 the largest element is 234
 the smallest element is 1  */