Page 1 of 1

Write a generic function that calculates and returns the absolute value of two numeric values (of the same type) passed

Posted: Thu May 05, 2022 2:00 pm
by answerhappygod
Write A Generic Function That Calculates And Returns The Absolute Value Of Two Numeric Values Of The Same Type Passed 1
Write A Generic Function That Calculates And Returns The Absolute Value Of Two Numeric Values Of The Same Type Passed 1 (39.39 KiB) Viewed 35 times
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; }