Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Find minimum of elements in Array

 This example will show you how to find a minimum of elements in an Array using C program.



The below findMin function takes two arguments and returns an integer.

int findMin(int *a, int n)


*a – pointer to an array

n – size of the array


Example

#include

int findMin(int *a, int n){
int min,i;
min
= a[0];
for(i=1;in;i++){
if(a[i]min){
min
= a[i];
}
}
return min;
}

main
(){
int i;
int size=5;
int a[5];
int min;
for(i=0;isize;i++){
a
[i]=i+100;
}
min
= findMin(a,size);
printf
("Minimum value in array is %d",min);
return;
}


Output

Minimum value in array is 100





This post first appeared on PHP Update Data In MySQL Database, please read the originial post: here

Share the post

Find minimum of elements in Array

×

Subscribe to Php Update Data In Mysql Database

Get updates delivered right to your inbox!

Thank you for your subscription

×