Hi,
I have situation in C++ where in I'll have to add around 20-25 conditions <compare a variable against a number> to an if statement.
Is there any limit on the number of expressions/conditions to be added to an if statement.
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++
sample code.
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++
x = 10;
if ( (x == 20) || (x == 22) || ) //I have around 20 comparisions here
{
//do something
}
if ( (x == 21) || (x == 22) )//I have around 20 comparisions here
{
//do something else
}
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++
Though the value of the 'x' is not any of the constants i am comparing with the stmts in all the if blocks are getting executed. i checked and re-checked the values to make sure that it is different but code isn't behaving as expected.
Can somebody help me.
Note that I can't use the switch the conditions as the constants in the if conditions are not mutually exclusive.
Thanks in advance
Prashanth