#include <stdio.h> #define NIBBLE 0x000F #define UPPER 4 #define LOWER 0 unsigned char extractNibble(unsigned char reg, int pos) { // Write your code here reg >>= pos ? UPPER : LOWER; return reg & NIBBLE; } int main() { unsigned char reg; int pos; scanf("%hhu %d", ®, &pos); printf("%d", extractNibble(reg, pos)); return 0; }
Test Cases
Test Results
Input
170 0
Expected Output
10