/*
The program MinimumOfTen displays the minimum number entered.
User enters 10 numbers from console.
*/
#include <iostream>
using namespace std;
/*
An array arr of double is sent to the function double minNumber(double*, int).
And amount of numbers in array arr is sent to the function double minNumber(double*, int).
The value of the double minInArr variable is returned.
*/
double minNumber(double*, int);
int main()
{
double arr[10];
cout << "Enter ten numbers: ";
for (int i = 0; i < 10; i++)
{
cin >> arr[i];
}
cout << "Minimum number: " << minNumber(arr, 10);
}
double minNumber(double* arr, int num)
{
double minInArr = arr[0];
for (int i = 1; i < num; i++)
{
if (minInArr > arr[i])
{
minInArr = arr[i];
}
}
return minInArr;
}
Comments
Leave a comment