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
using System ; class GFG { static int maximum ( int x , int y ) { return ( ( x + y + Math . Abs ( x - y ) ) / 2 ) ; } static int minimum ( int x , int y ) { return ( ( x + y - Math . Abs ( x - y ) ) / 2 ) ; } public static void Main ( ) { int x = 99 , y = 18 ; Console . WriteLine ( " Maximum : ▁ " + maximum ( x , y ) ) ; Console . WriteLine ( " Minimum : ▁ " + minimum ( x , y ) ) ; } }