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