How to find smallest number in array ?

Below code will help you to program of how to find smallest number in array.

#include<conio.h>
#include<stdio.h>
void main ()
{
int a[5],i,babu,n=5;
clrscr();
printf(“Enter %d numbers”,n);
for(i=0;i<=n-1;i++)
{
scanf(“%d”,&a[i]);
}
babu=a[0];
for(i=1;i<=n-1;i++)
{
if(babu>a[i])
babu=a[i];
}
printf(“Smallest number is :=%d”,babu);
getch();
}

After running program : )

Leave a Reply