Answer to Question #283861 in C++ for Yash gupta

Question #283861

write a c++ ,program to use function overloading with function template ( max two value)


1
Expert's answer
2021-12-31T01:42:11-0500

















// C++ program to demonstrate the

// function overloading

#include <bits/stdc++.h>

using namespace std;

  

// Function to calculate square

void square(int a)

{

    cout << "Square of " << a

         << " is " << a * a

         << endl;

}

  

// Function to calculate square

void square(double a)

{

    cout << "Square of " << a

         << " is " << a * a

         << endl;

}

  

// Driver Code

int main()

{

    // Function Call for side as

    // 9 i.e., integer

    square(9);

  

    // Function Call for side as

    // 2.25 i.e., double

    square(2.25);

    return 0;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog