Answers for "check if kth bit is set or not code"

C++
0

check if kth bit is set or not code

#include <iostream>
using namespace std;

//! Using LeftShift Operator

void kthBit(int n, int k)
{
    if (n & (1 << k - 1) != 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    int n, k;
    cin >> n >> k;
    kthBit(n, k);
    return 0;
}
Posted by: Guest on July-30-2021

Code answers related to "check if kth bit is set or not code"

Browse Popular Code Answers by Language