pointers-memory · intermediate · ~15 min

Reverse bits of a uint32

Bitwise shifts and masking.

Challenge

Implement uint32_t reverse_bits(uint32_t n) returning n with its 32 bits in reversed order.

Starter code

#include <stdint.h>
uint32_t reverse_bits(uint32_t n) { /* TODO */ return 0; }

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.