Write a program which will input some numbers in an integer array and pass this to a function called minimum (). This function will find the minimum of the array values and returns this value to the main () function for displaying it
#include <stdio.h>
#include<conio.h>
int minimum( int [] );
int minimum( int values[5] )
{
int min_value, i;
min_value = values[0];
for( i = 0; i < 5; ++i )
if( values[i] < min_value )
min_value = values[i];
return min_value;
}
main()
{
int values[5], i, min;
printf("Enter 5 numbers\n");
for( i = 0; i < 5; ++i )
scanf("%d", &values[i] );
min = minimum( values );
printf("\nminimum value is %d\n", min );
getch();
}
#include<conio.h>
int minimum( int [] );
int minimum( int values[5] )
{
int min_value, i;
min_value = values[0];
for( i = 0; i < 5; ++i )
if( values[i] < min_value )
min_value = values[i];
return min_value;
}
main()
{
int values[5], i, min;
printf("Enter 5 numbers\n");
for( i = 0; i < 5; ++i )
scanf("%d", &values[i] );
min = minimum( values );
printf("\nminimum value is %d\n", min );
getch();
}