#include <stdio.h> #include <stdint.h> void decode_status(uint8_t reg) { // Your logic here if(reg&1) printf("Power On\n"); reg>>=1; if(reg&1) printf("Error\n"); reg>>=1; if(reg&1)printf("Tx Ready\n"); reg>>=1; if(reg&1)printf("Rx Ready\n"); reg>>=1; if(reg&1)printf("Overheat\n"); reg>>=1; if(reg&1)printf("Undervoltage\n"); reg>>=1; if(reg&1)printf("Timeout\n"); reg>>=1; if(reg&1)printf("Reserved\n"); reg>>=1; } 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