69 757
Assignments Done
99,6%
Successfully Done
In February 2019

Answer to Question #63139 in C++ for Seng

Question #63139
Write a function that finds the smallest element in an array of double values using the following header:

double min(double list[], int size)

Write a test program that prompts the user to enter 10 numbers, invokes this function, and displays the minimum value. Here is a sample run of the program:

Enter ten numbers: 1.9 2.5 3.7 2 1.5 6 3 4 5 2 <enter>

The minimum number is 1.5
#include <iostream>
#include <conio.h>
using namespace std;

double min(double list[], int size)
{
double result = list[0];
for(int i = 1; i < size; i++)
if(result > list[i])
result = list[i];
return result;
}

int main()
{
double arr[10];
cout << "Enter ten numbers: ";
for(int i = 0; i < 10; i++)
cin >> arr[i];
if(cin.fail())
{
cout << "Wrong input!";
_getch();
return 1;
}
cout << "The minimum number is " << min(arr, 10);

_getch();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!