Create a program that will overload a function sum, which takes two
parameters of numeric data type and prints their sum function for
integers and floats.
#include<iostream>
using namespace std;
double sum(int x, int y)
{
cout << "Int sum: ";
return x + y;
}
double sum(float x, float y)
{
cout << "\nFloat sum: ";
return x + y;
}
int main()
{
int x = 10;
int y = 25;
float z = 3.34;
float q = 7.8;
cout<<sum(x, y);
cout<<sum(z, q);
}
Comments
Leave a comment