#include <iostream>
#include <cstdint>
using namespace std;
union ByteSplitter {
    uint16_t word;
    uint8_t bytes[2];
};
int main() {
    uint16_t val;
    cin >> val;
    ByteSplitter u;
    u.word = val;
    cout << "LSB=" << (int)u.bytes[0] << " MSB=" << (int)u.bytes[1];
    return 0;
}
Solution Details
👉 In simple words: The union is two “views” of the same memory — one as a full 16-bit value, one as two 8-bit chunks.
 
Significance for Embedded Developers
Input
4660
Expected Output
LSB=52 MSB=18