#include <stdio.h> #include <stdint.h> #define MAX_REG_BYTES (4) typedef union { uint32_t value; uint8_t bytes[MAX_REG_BYTES]; } Register; // Write logic here to extract bytes using union void print_bytes(uint32_t input) { // Your code here Register temp_reg; temp_reg.value = input; for(int i = 0; i < MAX_REG_BYTES; i++){ printf("%d ", temp_reg.bytes[i]); } } int main() { uint32_t num; scanf("%u", &num); print_bytes(num); return 0; }
Test Cases
Test Results
Input
305419896
Expected Output
120 86 52 18