#include <stdio.h> #include <stdint.h> uint32_t convert_endian(uint32_t value) { // Write logic to swap bytes //0x12345678 uint32_t val1 = (value >> 24) & 0x000000FF; // 0x00000012 uint32_t val2 = (value >> 8) & 0x0000FF00; //0x00003400 uint32_t val3 = (value << 8) & 0x00FF0000; //0x00560000 uint32_t val4 = (value << 24) & 0xFF000000; //0x78000000 value = val1|val2|val3|val4; return value; } int main() { uint32_t val; scanf("%u", &val); printf("%u", convert_endian(val)); return 0; }
Test Cases
Test Results
Input
305419896
Expected Output
2018915346