#include <stdio.h> #include <stdint.h> void decodeStatus(uint8_t status_reg) { // Lookup table for flag names const char* flags[8] = { "Power On", "Error", "Tx Ready", "Rx Ready", "Overheat", "Undervoltage", "Timeout", "Reserved" }; // Scan from bit 0 (LSB) to bit 7 (MSB) for (int bit = 0; bit < 8; bit++) { if (status_reg & (1u << bit)) { printf("%s\n", flags[bit]); } } } int main() { uint8_t reg; scanf("%hhu", ®); decodeStatus(reg); return 0; }
Solving Approach
Test Cases
Test Results
Input
13
Expected Output
Power On Tx Ready Rx Ready