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