#include <stdio.h> #include <stdint.h> typedef struct { unsigned short reg; } ConfigRegister; int validate_config(ConfigRegister *cfg) { // Write logic using pointer access uint16_t count=0; uint16_t temp=cfg->reg & (1<<0); if(temp==1){ uint16_t temp1=cfg->reg & (3<<2); if(temp1!=3){ for(int i=4; i<=15;i++){ if((cfg->reg & (1<<i))==0){ count++; } } } } if(count==12){ return 1; }else return 0; } int main() { ConfigRegister cfg; scanf("%hx", &cfg.reg); int result = validate_config(&cfg); printf("%d", result); return 0; }
Test Cases
Test Results
Input
0005
Expected Output
1