For loop with multiple conditions (boolean expr)
vinay · Tue Jan 11, 2022 9:37 am
The following two similar codes are giving different outputs.
The following code:
returns the expected answer, whereas the code
returns nothing.
Is this expected behaviour?
-- VInay
The following code:
Code:
for (i=1;i<=10;i++)
{
if ((i%2)!=1)
{
i;
}
}
{
if ((i%2)!=1)
{
i;
}
}
returns the expected answer, whereas the code
Code:
for (i=1;i<=10 && (i%2)!=1;i++)
{
i;
}
{
i;
}
returns nothing.
Is this expected behaviour?
-- VInay