Print Friendly and PDF
(Find the Minimum) Write a program that inputs three double-precision, floating-point numbers and passes them to a function that returns the smallest number.
(Find the Minimum) Write a program that inputs three double-precision, floating-point numbers and passes them to a function that returns the smallest number.
Solution: 
 
#include <iostream>
using std::cout;
using std::cin;
 
double smallest(double, double, double);
 
int main()
{
   double i, j, k;
 
   cout << "Enter three floating point numbers: ";
   cin >> i >> j >> k;
 
   cout << "The smallest is " << smallest(i, j, k);
 
   return 0;
}
 
double smallest(double i, double j, double k)
{
   double smal;
 
   smal = i;
   if( i > j)
   {
      if( j > k)
         smal = k;
      else
         smal = j;
   }
   else
   {
      if( i > k)
         smal = k;
   }
 
   return smal;
}
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: