C Program To Find Smallest Element in Array
Learn How To Find Smallest Element in Array in C Programming Language. It is important that we should know How A For Loop Works before getting further with the C Program Code.
To Search Minimum Element or the Smallest Element in an Array, we need to assign the First Element ( Index 0 ) as the Minimum. Then, Compare every other Element with Minimum. If the Element is Smaller than Minimum, then assign it to Minimum. This C Code makes use of Linear Search Algorithm to Find the Array Element.
Also Read: How To Find Maximum Element in 1-Dimension Array in C
C Program To Find Smallest Element in Array without Function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include<stdio.h> int main() { int arr[10], count, minimum; printf("\nEnter 10 Elements in Array:\t"); for(count = 0; count < 10; count++) { scanf("%d", &arr[count]); } printf("\nElements in Array are:\n"); for(count = 0; count < 10; count++) { printf("%d\t", arr[count]); } printf("\n"); minimum = arr[0]; for(count = 0; count < 10; count++) { if(arr[count] < minimum) { minimum = arr[count]; } } printf("\nMinimum Element in Array : %d\n", minimum); printf("\n"); return 0; } |
Output

In case you get any Compilation Errors with this C Program Code To Find Minimum Element of 1 Dimensional Array or if you have any doubt about it, let us know about it in the Comment Section below.
This was really an easy code. Thanks for helping me to find out the smallest array element in C.