Code a C++ function Min() that takes three double type arguments and that returns the
value of the smallest of the three arguments.
#include<iostream>
using namespace std;
double Min(double first, double second, double third){
double min = first;
if(second<third && second<first){
min = second;
}
else if(third < first && third< second){
min = third;
}
return min;
}
//Testing code
int main(){
double first, second, third;
cout<<"Enter the first number\n";
cin>>first;
cout<<"Enter the second number\n";
cin>>second;
cout<<"Enter the third number\n";
cin>>third;
cout<<"The value of the smallest number is: \t"<<Min(first, second, third);
}
Comments
Leave a comment