Question
improve (Re-write ) the following program by using the function overloading. ( in C++ ) #include using namespace std; int maximumInt( int value1, int value2,
improve (Re-write ) the following program by using the function overloading.
( in C++ )
#include using namespace std; int maximumInt( int value1, int value2, int value3 ) { int max = value1; if ( value2 > max ) max = value2; if ( value3 > max ) max = value3; return max; } double maximumDouble( double value1, double value2, double value3 ) { double max = value1; if ( value2 > max ) max = value2; if ( value3 > max ) max = value3; return max; } char maximumChar( char value1, char value2, char value3 ) { char max = value1; if ( value2 > max ) max = value2; if ( value3 > max ) max = value3; return max; } int main() { int int1, int2, int3; cout << "Input three integer values: "; cin >> int1 >> int2 >> int3; cout << "The maximum integer value is: " << maximumInt( int1, int2, int3 ); double double1, double2, double3; cout << " Input three double values: "; cin >> double1 >> double2 >> double3; cout << "The maximum double value is: " << maximumDouble( double1, double2, double3 ); char char1, char2, char3; cout << " Input three characters: "; cin >> char1 >> char2 >> char3; cout << "The maximum character value is: " << maximumChar( char1, char2, char3 ) << endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started