C Program to Find Minimum Element in Array

C Program :

/* Aim: Accept an array and print the minimum array element */  

#include<stdio.h>

void main()
{
	int i,j=0,arr[5],min;

	printf("\n Enter array elements(Max 5 elements):- ");
 
	for(i=0;i<=4;i++)
		scanf("%d",&arr[i]);

	min=arr[0];

	for(i=0;i<=4;i++)
	{
	if(arr[i]<min)
	min=arr[i];
	}

	printf("\n The minimum number in the given array is %d \n \n",min);
 
} // End of the code 


/* Output of above code:-

[fy87@ugilinux ~]$ cc minelarr.c
[fy87@ugilinux ~]$ ./a.out

 Enter array elements(Max 5 elements):- 41 40 39 100 102

 The minimum number in the given array is 39 
 

*/ 

Comments