#include <stdio.h> #include <stdint.h> uint8_t rotate_left(uint8_t reg, uint8_t n) { return ((reg << n)|(reg>>(8-n))) &0xFF; // Your code here } int main() { uint8_t reg, n; scanf("%hhu %hhu", ®, &n); printf("%u", rotate_left(reg, n)); return 0; }
rotate the no.of bist given to the left and also rotate the register to right to (8-n) values and perform the addition.. and as C expands so do the OR operation with 0xFF.. this will give the circular rotation!
Test Cases
Test Results
Input
176 1
Expected Output
97