Skip to content

Instantly share code, notes, and snippets.

@jjfajardo
Last active December 28, 2015 01:49
Show Gist options
  • Save jjfajardo/7423551 to your computer and use it in GitHub Desktop.
Save jjfajardo/7423551 to your computer and use it in GitHub Desktop.
minval.cpp find de min value in an array of C
#include <algorithm>
#include <iostream>
#include <vector>
#define NELEMS(x) (sizeof(x) / sizeof(x[0]))
using namespace std;
double minval(double x[])
{
int n = NELEMS(x)
int t;
double small = x[0];
for(t = 0; t < n; t++)
{
if(x[t] < small)
{
small = x[t];
}
}
return small;
}
int main()
{
double a[] = {3, 1, 4, 1, 5, 9};
cout << minval(a) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment