Pass array and its length to a function - C Function

C examples for Function:Function Parameter

Description

Pass array and its length to a function

Demo Code

#include <stdio.h>

int minimum (int values[], int numberOfElements){
    int minValue, i;

    minValue = values[0];//from   w  ww . ja  v a2 s  . c om

    for ( i = 1; i < numberOfElements; ++i )
        if ( values[i] < minValue )
            minValue = values[i];

    return minValue;
}

int main (void)
{
    int array1[5] = { 157, -28, -37, 26, 10 };
    
    printf ("array1 minimum %i\n", minimum (array1, 5));

    return 0;
}

Related Tutorials