#include <stdio.h> #include <stdint.h> typedef union { uint32_t value; uint8_t bytes[4]; } Register; // Write logic here using union to modify byte[1] and byte[2] void modify_and_print(uint32_t input, uint8_t b1, uint8_t b2) { // Your logic here Register r; r.value = input; r.bytes[1] = b1; r.bytes[2] = b2; printf("%u", (uint32_t) r.value); } int main() { uint32_t num; uint8_t b1, b2; scanf("%u %hhu %hhu", &num, &b1, &b2); modify_and_print(num, b1, b2); return 0; }
transfer the value to the register value, change the bytes 1 & 2,
then print the value of the register (unsigned 32bit int)
Test Cases
Test Results
Input
305419896 170 187
Expected Output
314288760