Question
Write a program that uses a function to find the highest number in an array containing 5 numbers.
In the main(), you must ask the user to enter 5 numbers and store these in the array.
Pass the array to a function and your function must find the highest number.
Return this number to your main() and display it.
Further
This is all I have written so far. Stuck on the operation to determine the highest number within the function. Any help would be appreciated.
#include <stdio.h>
#include <math.h>
#define SIZE 5
//function signatures
int getHighestNumber(int[]);
//main function
int main()
{
//main variables
int array[SIZE];
int highest_number;
int i;
printf("\nPlease enter 5 numbers into an array.\n");
for (i = 0; i < SIZE; i++)
{
scanf("%d", &array[i]);
}
int getHighestNumber(int array[SIZE]);
return 0;
}
int getHighestNumber(int array[])
{
//function variables
int highest_number;
int i;
for (i = 0; i < SIZE; i++)
{
if (array[i] > highest_number)
{
highest_number = array[i];
}
}
return highest_number;
}