Write a generic function that calculates and returns the absolute value of two numeric values (of the same type) passed
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Write a generic function that calculates and returns the absolute value of two numeric values (of the same type) passed
Write a generic function that calculates and returns the absolute value of two numeric values (of the same type) passed in (x-yl). The function should operate with any numeric data types (e.g. float, int, double). #include <iostream> using namespace std; // ----- ENTER YOUR CODE HERE ---- int main() { // Variable declarations int i1, 12; double d1, d2; i1 = 10; i2=20; cout << "Absolute value of 10,20 is " << absoluteValue(i1,i2) << endl; d1 = 5.5; d2=3.1; cout << "Absolute value of 5.5, 3.1 is " << absoluteValue(d1,d2) << endl; return 0; }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!