if and else if statements in C++ -
what difference between this:
s = 0; if (x > 0) s++; if (y > 0) s++;
and this:
s = 0; if (x > 0) s++; else if (y > 0) s++;
any appreciated.
when write else if instead of if, program not check else if statement if x > 0, when write 2 if statements program check both conditions, no matter if x > 0 or not.
Comments
Post a Comment