Home > Programming > Functions using the "C" programming language > example02.c

 

Previous

Next


/*
** Calculate the maximum element of the array elements **
*/
#include <stdio.h>
#define SIZE 4

int max( int[ ],int); /* function prototype */

void main()
{
    int array[SIZE] = {7,4,9,6};
    printf("%d",max(array,SIZE));
}

int max( int nums[ ],int size )
{
    int i;
    int max=nums[0];
    for(i=0;i<size;i++)
    {
        if(max<nums[i]) max=nums[i];
    }
    return max;
}


© 2004 Jim Valavanis

Previous

Next

1