For every set bit of a number toggle bits of other | A CPP program toggle bits of n2 that are at same position as set bits of n1 . ; function for the Nega_bit ; Driver program to test above
#include <bits/stdc++.h> NEW_LINE using namespace std ; int toggleBits ( int n1 , int n2 ) { return n1 ^ n2 ; } int main ( ) { int n1 = 2 , n2 = 5 ; cout << toggleBitst ( n1 , n2 ) << endl ; return 0 ; }