Find Maximum and Minimum of two numbers using Absolute function | C ++ program to find maximum and minimum using Absolute function ; Function to return maximum among the two numbers ; Function to return minimum among the two numbers ; Driver code ; Displaying the maximum value ; Displaying the minimum value
#include <bits/stdc++.h> NEW_LINE using namespace std ; int maximum ( int x , int y ) { return ( ( x + y + abs ( x - y ) ) / 2 ) ; } int minimum ( int x , int y ) { return ( ( x + y - abs ( x - y ) ) / 2 ) ; } int main ( ) { int x = 99 , y = 18 ; cout << " Maximum : ▁ " << maximum ( x , y ) << endl ; cout << " Minimum : ▁ " << minimum ( x , y ) << endl ; return 0 ; }