Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This purpose of this problem is to work with function overloading. You will writ

ID: 674123 • Letter: T

Question

This purpose of this problem is to work with function overloading. You will write several versions of functions called find_min(), get_input() and print_min(). print_min() and get_input() will be void functions. find_min() will return a value. The functions are as follows:

The first version of print_min() will take one integer argument and print the message "The minimum is <value>. ", where <value> is the contents of the integer argument.

The second version of print_min() will take one double argument and print the message "The minimum is <value>. " with 4 decimal places of precision for <value>.

The first version of find_min() will take two integer arguments and it will return the minimum of the two integers.

The second version of find_min() will take two double arguments and it will return the minimum of the two doubles.

The third version of find_min() will take three integer arguments and it will return the minimum of the three integers.

The first version of get_input() has two by-reference integer arguments. It will prompt the user for two integers and read them into the by-reference parameters.

The second version of get_input() has two by-reference double arguments. It will prompt the user for two doubles and read them into the by-reference parameters.

The third version of get_input() has three by-reference integer arguments. It will prompt the user for three integers and read them into the by-reference parameters.

Use the following main function for this problem:

Explanation / Answer

The call by reference method of passing arguments to a function copies the reference of an argument into the formal parameter. Inside the function, the reference is used to access the actual argument used in the call. This means that changes made to the parameter affect the passed argument.

Function overloading means two or more functions can have the same name but either the number of arguments or the data type of arguments has to be different. Return type has no role because function will return a value when it is called and at compile time compiler will not be able to determine which function to call.

#include <iostream>

int main()
{
int num1, num2, num3;
double dnum1, dnum2;
// Two integer version
int get_input(num1, num2){
   cout <<"Enter num to Num1,num2"<<endl;
   cin >> num1 >>num2;
print_min(find_min(num1, num2));
if (num1<num2)
{
      cout<<"num1 is small"<<num1;
}else {
     cout <<" num2 is small"<< num2;
}
  
}
// Two double version
double get_input(dnum1, dnum2){

cout <<"Enter num to Num1,num2"<<endl;
   cin >> dnum1 >>dnum2;
print_min(find_min(dnum1, dnum2));
if (dnum1<dnum2)
{
      cout<<"num1 is small"<<dnum1;
}else {
     cout <<" num2 is small"<< dnum2;
}

}

// Three integer version
int get_input(num1, num2, num3){
   cout <<"Enter num to Num1,num2, num3"<<endl;
   cin >> num1 >>num2>>num3;
print_min(find_min(num1, num2,num3));
if((num1<num2)&&(num1<num3)){
      cout<<"num 1 is small"<<num1;
}else if((num2<num3)&&(num2<num1)){
      cout<<"num2 is small"<<num2;
}else {
      cout<<"num3 is small"<<num3;
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote