Flip all K | C # program for the above approach ; Function to flip all K - bits of an unsigned number N ; Stores ( 2 ^ K ) - 1 ; Update N ; Print the answer ; Driver Code
using System ; class GFG { static void flippingBits ( int N , int K ) { int X = ( 1 << ( K - 1 ) ) - 1 ; N = X - N ; Console . Write ( N ) ; } public static void Main ( string [ ] args ) { int N = 1 , K = 8 ; flippingBits ( N , K ) ; } }