C++
Write a program that inputs ten double-precision, floating-point numbers and passes them to a function that returns the smallest number (note: use pointers).
code c++
#include <iostream>
using namespace std;
double smallest(double *arr)
{
double small=9007199254740992.0;
for(int i=0;i<10;i++)
{
if(small > arr[i])
small = arr[i];
}
return small;
}
int main() {
double arr[10];
for(int i=0;i<10;i++)
{
cout<<"Enter "<<i+1<<" number : ";
cin>>arr[i];
}
cout<<"The smallest number is : "<<smallest(arr);
}
output screenshot
Get Answers For Free
Most questions answered within 1 hours.