Search This Blog

Translate

c program to find largest and smallest element of array

c program to find largest and smallest element of array



#include
#include
void main()
{
 int n[10],i,max,min;
 clrscr();
 for(i=0;i<10 br="" i=""> {
  printf("\n Enter the  %d element:",i);
  scanf("%d",&n[i]);
  }  max=min=n[0];
  for(i=0;i<10 br="" i="">  {
   if(n[i]     min=n[i];
   if(n[i]>max)
    max=n[i];
 }
 printf("\n The largest number is:%d",max);
 printf("\n The smallest number is:%d",min);
 getch();
}

C Program example List

Google+ Badge