#include <stdio.h>
#include <stdint.h>
#define poweron (1<<0)
#define error (1<<1)
#define txready (1<<2)
#define rxready (1<<3)
#define overheat (1<<4)
#define uv (1<<5)
#define time (1<<6)
#define res (1<<7)
void decode_status(uint8_t status_reg) {
// Your logic here
if (status_reg & poweron) printf("Power On\n");
if (status_reg & error) printf("Error\n");
if (status_reg & txready) printf("Tx Ready\n");
if (status_reg & rxready) printf("Rx Ready\n");
if (status_reg & overheat) printf("Overheat\n");
if (status_reg & uv) printf("Undervoltage\n");
if (status_reg & time) printf("Timeout\n");
if (status_reg & res) printf("Reserved\n");
}
int main() {
uint8_t reg;
scanf("%hhu", ®);
decode_status(reg);
return 0;
}Solving Approach
Input
13
Expected Output
Power On Tx Ready Rx Ready