Print all submasks of a given mask | C ++ Program for above approach ; Function to print the submasks of N ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void SubMasks ( int N ) { for ( int S = N ; S ; S = ( S - 1 ) & N ) { cout << S << " ▁ " ; } } int main ( ) { int N = 25 ; SubMasks ( N ) ; return 0 ; }