Computer Science, asked by charulata32, 2 months ago

create c++ program of 2 or 3 numbers using function overloading​

Answers

Answered by HelloVaibhav
1

Answer:

// Program to compute absolute value

// Works for both int and float

#include <iostream>

using namespace std;

// function with float type parameter

float absolute(float var){

if (var < 0.0)

var = -var;

return var;

}

// function with int type parameter

int absolute(int var) {

if (var < 0)

var = -var;

return var;

}

int main() {

// call function with int type parameter

cout << "Absolute value of -5 = " << absolute(-5) << endl;

// call function with float type parameter

cout << "Absolute value of 5.5 = " << absolute(5.5f) << endl;

return 0;

}

Explanation:

MY MOST GORGEOUS SISTER PLEASE FOLL!OW ME

Similar questions