#include <stdio.h> #include <stdint.h> #include <iostream> using namespace std; void decode_status(uint8_t status_reg) { // Your logic here uint8_t reg = status_reg; if(reg & (1<<0)) std::cout<<"Power On"<<endl; if(reg & (1<<1)) std::cout<<"Error"<<endl; if(reg & (1<<2)) std::cout<<"Tx Ready"<<endl; if(reg & (1<<3)) cout<<"Rx Ready"<<endl; if(reg & (1<<4)) cout<<"Overheat"<<endl; if(reg & (1<<5)) cout<<"Undervoltage"<<endl; if(reg & (1<<6)) cout<<"Timeout"<<endl; if(reg & (1<<7)) cout<<"Reserved"<<endl; } 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