Answer to Question #293313 in C++ for Cherry ann

Question #293313

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.





1
Expert's answer
2022-02-02T12:48:42-0500
#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);
}	

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