C++ Function Overloads Question

Introduction

Write a program that has two function overloads.

The functions are called division, and both accept two parameters.

They divide the parameters and return the result to themselves.

The first function overload is of type int and has two parameters of types int.

The second overload is of type double and accepts two parameters of type double.

Invoke the appropriate overload in main, first by supplying integer arguments and then the double arguments.

Observe different results.

You can use the following code structure.

#include <iostream> 

int main() 
{ 
    //your code here
} 


#include <iostream> 
#include <string> 

int division(int x, int y) 
{ 
    return x / y; 
} 

double division(double x, double y) 
{ 
    return x / y; 
} 

int main() 
{ 
    std::cout << "Integer division: " << division(9, 2) << '\n'; 
    std::cout << "Floating point division: " << division(9.0, 2.0); 
} 



PreviousNext

Related