Set the Bit in an 8-bit Register

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
 

 

 

Upvote
Downvote
Loading...

Input

5 1

Expected Output

7