#include <stdio.h> #include <stdint.h> void convert_to_big_endian(uint32_t value, uint8_t arr[4]) { // Your code here uint8_t b_3 = value & 0xFF; uint8_t b_2 = value >> 8 & 0xFF; uint8_t b_1 = value >> 16 & 0xFF; uint8_t b_0 = value >> 24 & 0xFF; arr[0] = b_0; arr[1] = b_1; arr[2] = b_2; arr[3] = b_3; } int main() { uint32_t value; uint8_t arr[4]; scanf("%u", &value); convert_to_big_endian(value, arr); for (int i = 0; i < 4; i++) { printf("%u", arr[i]); if(i<3){ printf(" "); } } return 0; }
Test Cases
Test Results
Input
305419896
Expected Output
18 52 86 120