#include <stdio.h> unsigned char setBit(unsigned char reg, int pos) { return reg | (1 << pos); // set the pos-th bit } int main() { unsigned char reg; int pos; scanf("%hhu %d", ®, &pos); unsigned char result = setBit(reg, pos); printf("%d\n", result); return 0; }
Test Cases
Test Results
Input
5 1
Expected Output
7