programming-examples/c/Search_Sorting/C Program to Find Minimum Element in an Array using Linear Search.c

27 lines
571 B
C
Raw Normal View History

2019-11-15 12:59:38 +01:00
#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;
}