Set the K | C ++ implementation to set the kth bit of the given number ; function to set the kth bit ; kth bit of n is being set by this operation ; Driver program to test above
#include <bits/stdc++.h> NEW_LINE using namespace std ; int setKthBit ( int n , int k ) { return ( ( 1 << k ) n ) ; } int main ( ) { int n = 10 , k = 2 ; cout << " Kth ▁ bit ▁ set ▁ number ▁ = ▁ " << setKthBit ( n , k ) ; return 0 ; }