#include <stdio.h>
#include "arrays.h"
#define SIZE 14
int main (void)
{
int a[SIZE] = {101,56,78,23,74,364,53,5,83,12,89,44,77,178};
printf ("Smallest number in array is: %d.\n", findsmall(a,SIZE));
printf ("Largest number in array is: %d.\n", findlarge(a,SIZE));
printf ("Smallest even number in array is: %d.\n", findsmalleven(a,SIZE));
printf ("Largest even number in array is: %d.\n", findlargeeven(a,SIZE));
printf ("Smallest odd number in array is: %d.\n", findsmallodd(a,SIZE));
printf ("Largest odd number in array is: %d.\n", findlargeodd(a,SIZE));
return (0);
}
//content of library "arrays.h"
int findsmall (int arr[], int size)
{
int i, small;
small = arr[0];
for (i = 0; i < size; ++i)
if (arr[i] < small) small = arr[i];
return (small);
}
int findlarge (int arr[], int size)
{
int i, large;
large = arr[0];
for (i = 0; i < size; ++i)
if (arr[i] > large) large = arr[i];
return (large);
}
int findsmalleven (int arr[], int size)
{
int i, small;
small = arr[0];
for (i = 0; i < size; ++i)
if (arr[i] < small && arr[i]%2==0) small = arr[i];
return (small);
}
int findlargeeven (int arr[], int size)
{
int i, large;
large = arr[0];
for (i = 0; i < size; ++i)
if (arr[i] > large && arr[i]%2==0) large = arr[i];
return (large);
}
int findsmallodd (int arr[], int size)
{
int i, small;
small = arr[0];
for (i = 0; i < size; ++i)
if (arr[i] < small && arr[i]%2==1) small = arr[i];
return (small);
}
int findlargeodd (int arr[], int size)
{
int i, large;
large = arr[0];
for (i = 0; i < size; ++i)
if (arr[i] > large && arr[i]%2==1) large = arr[i];
return (large);
}