How change number for variable

I'm doing with own code, variable number try change for "if" but same stay "hold==0" how let change number like from "hold==0;" to "hold==2;"

int hold; . . . if (hold==0) { void xxxxxx(); . hold==2; //try change to 2 from 0 }

how what code let change to 2 from 0? "hold==2;" no error but didnt changed is 2 after 0 when "if (hold==0)" still often passing.

Can you try again, those words make no sense.

double == is a comparison single = is an assignment

Well done robtillaart for spotting what he was confused about.

Just to make the point To change the value of a variable use:- hold = 0 to test the value of a variable use:- if( hold == 0 )

Always use == inside an if statement never outside it.

robtillaart, realized, single = is an assignment that change the value of variable, perfect works. Grumpy_Mike, I got it, thanks.

Grumpy_Mike: Always use == inside an if statement never outside it.

Not completely true, sometimes there is no if statement (visible)

bool engineStarted = (digitalRead(enginePin) == HIGH);

or

if (Serial.available())
{
  c = Serial.Read();
  digitalWrite(somePin, c == 'h');
}

These code constructs can always be rewritten to an if statement

if (Serial.available())
{
  c = Serial.Read();
  if (c=='h') digitalWrite(somePin, HIGH);
  else digitalWrite(somePin, LOW);
}

There are strange constructions possible with == like

bool x = ((a==b) == (c==d)); // to be extended infinitely