Bit Operations using Macros

Code

#include <stdio.h>
#include <stdint.h>


#define mod_reg(reg)  (((reg | 0b10000100) & (~(0b00001000))) ^ 0b00100000)             
// Define bitwise macros here

uint8_t modify_register(uint8_t reg) {
    // Apply operations in order
    return mod_reg(reg);
}

int main() {
    uint8_t reg;
    scanf("%hhu", &reg);
    printf("%u", modify_register(reg));
    return 0;
}

Solving Approach

 

 

 

Upvote
Downvote
Loading...

Expected Output

164