set the jth bit from 1 to 0

#include <iostream>

int main() {
    int num, j;

    // Input: Taking an integer and the bit position j as input
    std::cout << "Enter an integer: ";
    std::cin >> num;
    std::cout << "Enter the bit position (0-based) to set to 0: ";
    std::cin >> j;

    // Shifting 1 to the left by j positions to create a mask
    int mask = 1 << j;

    // Performing a bitwise AND operation with the bitwise negation of the mask
    num = num & ~mask;

    // Output: Displaying the result after setting the jth bit to 0
    std::cout << "Result after setting the " << j << "th bit to 0: " << num << std::endl;

    return 0;
}