Q:

Alterations with a integer in c++

This is easy for you. I am busy with a test using c++. I have 2 values:
0 and 1

I can find random number between. Now i want to alternate between them. If i get "1" in step one then in step two I want to get "0" and in step three "1" again where it alternate
step1 = 1
step2 = 0
step3 = 1
step4 = 0

I tried increment and decrements
  int value;
  if(value == 0)
  {   
      value = value + 1;
  }
  else if(value == 1)
  {
      value = value -1;
  }

This code does not work. If it sees a 0 it will become 1 but the next step the value will be 1 again.

A:

If you really only ever need 0 and 1:
unsigned int value = 0;

while (1) {
   value = (value + 1) & 1;
   // do whatever is needed with value;
}

This works because in binary 0 + 1 = 1, and 1 + 1 = 10. The '& 1' portion tells us to always take the last bit.

