Answer to Question #100735 in C++ for Sadvabana Sahu

Question #100735
Write a value returning function smaller to determine the smallest number from a set of numbers.Ise this function to determine the smallest number from a set of 10 number
1
Expert's answer
2019-12-24T04:43:34-0500

/*

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;

}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS