C++ || STL || standard template libraries

Image
                                       C++ STL  1.      Pair :  Syntax :      pair <int,char> p1;     it creates a pair {2,'c'} like this.           pair <int,int> p2;     it creates a pair {2,3} like this .  Basic Code :  #include <bits/stdc++.h> using namespace std; int main() {     // cout<<"hello world\n";     pair <int,int> p1 = {1,2};     cout<<p1.first<< " "<< p1.second<<endl;          pair <int, pair<int ,char>> p2 = {1,{2,'c'}};     cout<<p2.first<<" "<<p2.second.first<<" "<<p2.second.second<<endl;          pair <int,int> arr[] = {{2,3},{4,5},{6,7}};     cout...

c program to clear nth bit of the number || Bitwise Operators || Problem Solving ||


#include <stdio.h>

int main()
{
    int num, n, newNum;

    printf("Enter any number: ");
    scanf("%d", &num);

    printf("Enter nth bit to clear (0-31): ");
    scanf("%d", &n);

    newNum = num & (~(1 << n));

    printf("Number before clearing %d bit: %d (in decimal)\n", n, num);
    printf("Number after clearing %d bit: %d (in decimal)\n", n, newNum);

    return 0;
}


Logic :-  num&(~(1<<n));

Comments

Popular posts from this blog

1050. Actors and Directors Who Cooperated At Least Three Times || Leetcode sql solution || Simple and Easy Approach || ✅✅✅✅💯💯💯🔥🔥🔥🔥

Power of Millets || Happy And Healthy Life

AI in Daily Life