Toggle the last m bits | C # implementation to toggle the last m bits ; Function to toggle the last m bits ; Calculating a number ' num ' having ' m ' bits and all are set ; Toggle the last m bits and return the number ; Driver Code
using System ; namespace Toggle { public class GFG { public static int toggleLastMBits ( int n , int m ) { int num = ( 1 << m ) - 1 ; return ( n ^ num ) ; } public static void Main ( ) { int n = 107 , m = 4 ; n = toggleLastMBits ( n , m ) ; Console . Write ( n ) ; } } }