Hi Narue,
Ive been playing around with the code you gave me and alltough I'm pretty sure I understand what is happening, I can't really figure out how this is going to help me in getting four different numbers smaller then 16 into one variable x :o
I understand that when having four bits 1111, I get a decimal maximum of 15.
I understand that by using those binary operators << or >> you can shift the binary to the left or right adding a ZERO to the four bits and changing the decimal number.
I understand that using the code x = bit(i) | 1; am putting the bit (i) to 1 and changing the decimal number again.
Have a few question about it also
#define bit(x) (1UL << (x))
int main()
{
unsigned int x=0;
x |= bit(0) | 1; // 00000001 = 1
cout<< x <<endl;
x |= bit(1) | 1; // 00000011 = 3
cout<< x <<endl;
cout<< (x >> 1 << 1) <<endl; // 00000010 = 2
x |= bit(2) | 1; // 00000111 = 7
cout<< x <<endl;
x |= bit(6) | 1; // 01000111 = 71
cout<< x <<endl;
// Get back a sliver
cout<< (x >> 1) <<endl; // 00100011 = 35
cout<< (x >> 2 << 2) <<endl; // 01000100 = 68
cout<< (x >> 1) <<endl; // 00100011 = 35
cout<< (x >> 1 << 1) <<endl; // 01000110 = 70
cout<< (x >> 2 << 1) <<endl; // 00100010 = 34
return 0;
}
1) #define bit(x) (1UL << (x)): what does the UL stand for and what does it do? Unsigned Long?
Also, when I deleted UL and left (1 << (x)) it worked aswell, with this the binary operator makes it shift one place to the left.
2) Tough I understand what happens when using these binary operators, I can't really figure out how this is going to help me getting those four decimal numbers into a variable x

Not only that, but when they are entered, I have to retrieve one of them using a number from 0 to 3, so, when I have decimal numbers entered like:
3
7
14
6
And I enter for example 1, it should give me 7 as result, sorry, but I don't see how this could be done with the example code you gave me :o
If you could give me any further hints, I would greatly appreciate it.