#include <stdio.h> #include <stdint.h> uint32_t convert_endian(uint32_t value) { // Write logic to swap bytes uint32_t temp=value; uint8_t t1= (temp >>0 )& 0xFF; uint8_t t2= (temp >>8)&0xFF; uint8_t t3= (temp>>16)&0xFF; uint8_t t4=(temp>>24)&0xFF; temp= (temp &~(0xFF<<0) | (t4<<0) ); temp= (temp &~(0xFF<<8) | (t3<<8)) ; temp= (temp &~(0xFF<<16) |(t2<<16)) ; temp= (temp &~(0xFF<<24) |(t1<<24)); return temp; } int main() { uint32_t val; scanf("%u", &val); printf("%u", convert_endian(val)); return 0; }
Test Cases
Test Results
Input
305419896
Expected Output
2018915346