text: Find average of two numbers using bit operation | C # implementation of the approach ; Function to return the average of x and y using bit operations ; Calculate the average Floor value of ( x + y ) / 2 ; Driver code
code: using System ; class GFG { static int getAverage ( int x , int y ) { int avg = ( x & y ) + ( ( x ^ y ) >> 1 ) ; return avg ; } public static void Main ( ) { int x = 10 , y = 9 ; Console . WriteLine ( getAverage ( x , y ) ) ; } }