programming-examples/c/Search_Sorting/C Program to Find Minimum Element in an Array using Linear Search.c
2019-11-15 12:59:38 +01:00

27 lines
571 B
C

#include <stdio.h>
#define MAX 10
int min_linearsearch(int numbers[])
{
int min = numbers[0];
int i;
for (i = 1; i < MAX; i++)
{
if (min > numbers[i])
min = numbers[i];
}
return min;
}
int main()
{
int numbers[MAX];
int i;
int min ;
printf("Enter %d numbers : ", MAX);
for (i = 0; i < MAX; i++)
{
scanf("%d", &numbers[i]);
}
min = min_linearsearch(numbers);
printf("\nMinimum number in the array is : %d\n", min);
return 0;
}