Wednesday, May 16, 2018

|| and && Operators


The "||" and "&&" operators, and/or respectively, are generally used for If statements, and either evaluate to the Boolean values True or False. The way it works is simple, the operator is put between two other "==" statements, and for the AND operator, if (1==1&&2==2) the statement will evaluate to true. If only one statement is true, then the whole statement is false. The OR operator works so that if (water == water || 2 == 1), even though 2 is not equal to 1 half of the statement is true so the entire statement is true.

Thursday, May 10, 2018

If statements

Related image
In most programming languages there are statements called "If-statements" which, as shown in the above diagram, check to see if a statement comes out to be true or false. If the statement, such as "if (1==1){" will execute the code to the next brace. In C++, you have to remember that the "=" operator is the assignment operator which assigns the value of the object on the left to the variable on the right.