4. Set the Bit in an 8-bit Register

Back To All Submissions
Previous Submission
Next Submission

Code

#include<stdio.h>
int main()
{
    int reg,pos;
    scanf("%hhu %d",&reg,&pos);
    int mask = 1<<pos;
    reg = reg | mask;
    printf("%hhu",reg);
    return 0;
}

Solving Approach
 

 

 

Was this helpful?
Upvote
Downvote