normal code with to modify specific bit

PHOTO EMBED

Mon Nov 25 2024 18:03:23 GMT+0000 (Coordinated Universal Time)

Saved by @Narendra

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,m;
    cout<<"Please enter the number";
    cin>>n;
    cout<<"please enter the bit u want to manipulate";
    cin>>m;
    cout<<"we are printing all the bits in this number";
    int bits = sizeof(n) * 4;
    for(int i=bits-1;i>=0;i--)
    {
        int bit = (n>>i)&1;
        cout<<bit;
    }
    cout<<endl;
    cout<<"now we want to manipulate bit";
    n = n^(1<<m);
    cout<<"the main vlue    "<<n<<endl;
    for(int i=bits-1;i>=0;i--)
    {
        int bit = (n>>i)&1;
        cout<<bit;
    }
    
}
content_copyCOPY