Non | C ++ program for the above approach ; Function to print all pairs whose sum of Bitwise OR and AND is N ; Iterate from i = 0 to N ; Print pairs ( i , N - i ) ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void findPairs ( int N ) { for ( int i = 0 ; i <= N ; i ++ ) { cout << " ( " << i << " , ▁ " << N - i << " ) , ▁ " ; } } int main ( ) { int N = 5 ; findPairs ( N ) ; return 0 ; }