home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tyc
/
list9_4.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-16
|
791b
|
41 lines
/* Passing an array to a function. */
#include <stdio.h>
#define MAX 10
int array[MAX], count;
int largest(int x[], int y);
main()
{
/* Input MAX values from the keyboard. */
for (count = 0; count < MAX; count++)
{
printf("Enter an integer value: ");
scanf("%d", &array[count]);
}
/* Call the function and display the return value. */
printf("\n\nLargest value = %d", largest(array, MAX));
}
/* Function largest() returns the largest value */
/* in an integer array */
int largest(int x[], int y)
{
int count, biggest = -12000;
for ( count = 0; count < y; count++)
{
if (x[count] > biggest)
biggest = x[count];
}
return biggest;
}