text: Compute maximum of two integers in C / C ++ using Bitwise Operators | C program for the above approach ; Function to find the largest number ; Perform the subtraction ; Right shift and Bitwise AND ; Find the maximum number ; Return the maximum value ; Driver Code ; Function Call
code: #include <stdio.h> NEW_LINE int findMax ( int a , int b ) { int z , i , max ; z = a - b ; i = ( z >> 31 ) & 1 ; max = a - ( i * z ) ; return max ; } int main ( ) { int A = 40 , B = 54 ; printf ( " % d " , findMax ( A , B ) ) ; return 0 ; }