#include <stdio.h> #include <stdint.h> typedef union { uint32_t value; uint8_t bytes[4]; } Register; // Write logic here to extract bytes using union void print_bytes(uint32_t input) { // Your code here uint8_t val = 0; val = (input & 0xFF); printf("%d ", val); val = ((input >> 8) & 0xFF); printf("%d ", val); val = ((input >> 16) & 0xFF); printf("%d ", val); val = ((input >> 24) & 0xFF); printf("%d", val); } 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