Programming in C

(Barry) #1
Functions and Arrays 139

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


minValue = values[0];

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

return minValue;
}


int main (void)
{
int scores[10], i, minScore;
int minimum (int values[10]);


printf ("Enter 10 scores\n");

for ( i = 0; i < 10; ++i )
scanf ("%i", &scores[i]);

minScore = minimum (scores);
printf ("\nMinimum score is %i\n", minScore);

return 0;
}


Program 8.9 Output


Enter 10 scores
69
97
65
87
69
86
78
67
92
90


Minimum score is 65


Program 8.9 Continued
Free download pdf