1. Set or Clear a Specific Bit in a Register

Back To All Submissions
Previous Submission
Next Submission

Code

#include <stdio.h>


int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(c == 1)
    {
        a |= (1 << b);
        printf("%d", a);
    }
    else if(c == 0)
    {
        a &= ~(1 << b);
        printf("%d", a);
    }
}

Solving Approach

 

 

 

Was this helpful?
Upvote
Downvote