Answers for "how to declare function with multiple parameter c++"

C++
0

how to declare function with multiple parameter c++

// overloaded function
#include <iostream>
using namespace std;

int operate (int a, int b)
{
  return (a*b);
}

float operate (float a, float b)
{
  return (a/b);
}

int main ()
{
  int x=5,y=2;
  float n=5.0,m=2.0;
  cout << operate (x,y);
  cout << "\n";
  cout << operate (n,m);
  cout << "\n";
  return 0;
}
/*
//Using template->
#include <iostream>

using namespace std;

template<typename Yourname> //U can write class instead of typename

void print (Yourname value)
{
    cout<<value;


}

int main()
{
print<int>(2);	//you can also use-> print(2);
cout<<endl;
print("ali");
}
*/
Posted by: Guest on February-26-2020

Code answers related to "how to declare function with multiple parameter c++"

Browse Popular Code Answers by Language