Pages

Friday, May 2, 2025

Clear ith bit - Bit Manipulation in C++

 #include <iostream>

using namespace std;


int setIthBit(int num, int i) {

    int bitMask = 1 << i;

    return (num | bitMask);

}


int clearIthBit(int num, int i) {

    int bitMask = ~(1 << i);

    return num & bitMask;

}


int main()

{

    cout<< clearIthBit(6, 1) << endl;


    return 0;A

}

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...