/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
unsigned int i[6]{0,1,2,4,8,16};
unsigned long* l = (unsigned long*)i;
cout<<"sizeof(char)=" << sizeof(char) << "\n";
cout<<"sizeof(unsigned int)=" << sizeof(unsigned int) << "\n";
cout<<"i[0] = " << i[0] << "\n";
cout<<"i[1] = " << i[1] << "\n";
cout<<"i[2] = " << i[2] << "\n";
cout<<"i[3] = " << i[3] << "\n";
cout<<"i[4] = " << i[4] << "\n";
cout<<"i[5] = " << i[5] << "\n";
cout<<"sizeof(unsigned long)=" << sizeof(unsigned long) << "\n";
cout<<"l[0] = " << l[0] << "\n";
cout<<"l[1] = " << l[1] << "\n";
cout<<"l[2] = " << l[2] << "\n";
int ni = 5;
while (ni >= 0){
cout << "i[" << ni << "] = ";
int pi = sizeof(unsigned int)*8-1;
while (pi>=0){
if ((((unsigned int)1<<pi) & i[ni]) > 0){
cout << 1;
}
else {
cout << 0;
}
if (pi % 8 == 0){ cout << " ";}
pi--;
}
cout << "\n";
ni--;
}
int nl = 2;
while (nl >= 0){
cout << "l[" << nl << "] = ";
int pl = sizeof(unsigned long)*8-1;
while (pl>=0){
if ((((unsigned long)1 <<pl) & l[nl]) != 0){
cout << 1;
}
else {
cout << 0;
}
if (pl % 8 == 0){ cout << " ";}
pl--;
}
cout << "\n";
nl--;
}
return 0;
}