// 8-bit integer interpretation // #include // Prior to C++20 header file for input and output // import ; // Since C++20 // #include // Header for bitset (binary representation) import std; // Since C++23 STD Module for standard data types and functions using std::cout; using std::endl; int main() { // Type char is used to define 8-bit numbers unsigned char u1; // unsigned 8-bit integer signed char s1; // signed 8-bit integer u1 = 100; cout << "Unsigned u1: Binary = " << std::bitset<8>(u1) << " ; Decimal = " << static_cast(u1) << endl; s1 = u1; // u1 is assigned to s1 cout << "Signed s1: Binary = " << std::bitset<8>(s1) << " ; Decimal = " << static_cast(s1) << endl; cout << "---------------------------" << endl; u1 = 255; cout << "Unsigned u1: Binary = " << std::bitset<8>(u1) << " ; Decimal = " << static_cast(u1) << endl; s1 = u1; // u1 is assigned to s1. Decimal 255 cannot be reprsesented as an 8-bit signed integer! cout << "Signed s1: Binary = " << std::bitset<8>(s1) << " ; Decimal = " << static_cast(s1) << endl; return 0; }