Comparing leading zeros in binary representations of two numbers | CPP program to find the number with more leading zeroes . ; Function to compare the no . of leading zeros ; if both have same no . of leading zeros ; if y has more leading zeros ; Main Function
#include <bits/stdc++.h> NEW_LINE using namespace std ; void LeadingZeros ( int x , int y ) { if ( ( x ^ y ) <= ( x & y ) ) cout << " Equal " else if ( ( x & ( ~ y ) ) > y ) cout << y ; else cout << x ; } int main ( ) { int x = 10 , y = 16 ; LeadingZeros ( x , y ) ; return 0 ; }