#include <stdio.h>
#include <stdint.h>
void decode_status(uint8_t status_reg) {
// Your logic here
printf((status_reg & 0x01) == 0x01 ? "Power On\n" : "");
printf((status_reg & 0x02) == 0x02 ? "Error\n" : "");
printf((status_reg & 0x04) == 0x04 ? "Tx Ready\n" : "");
printf((status_reg & 0x08) == 0x08 ? "Rx Ready\n" : "");
printf((status_reg & 0x10) == 0x10 ? "Overheat\n" : "");
printf((status_reg & 0x20) == 0x20 ? "Undervoltage\n" : "");
printf((status_reg & 0x40) == 0x40 ? "Timeout\n" : "");
printf((status_reg & 0x80) == 0x80 ? "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