[Solved] how to check if the integer is between -20 to +20 in c++ [closed]


You don’t need to use an loop – just an if conditional:

if((diff >= -20) && (diff <= 20)){
  // do something
}

&& is the logical AND Operator – it connects multiple conditions and the expression evaluates only to true, if both conditions are fullfilled.

See also here

solved how to check if the integer is between -20 to +20 in c++ [closed]