#include <stdio.h> typedef union { unsigned short reg; struct{ unsigned int set : 1; unsigned int mode: 1; unsigned int vp : 2; unsigned int res: 12; }; } ConfigRegister; int validate_config(ConfigRegister *cfg) { // Write logic using pointer access //printf("%d\n",cfg->set); //printf("%d\n",cfg->vp); if((cfg->set == 1) && (cfg->vp < 3) && (cfg->res == 0)){ 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