Condition statements, also sometimes referred to as control statements are a very essential part of programming. Condition statements are the decision points in code. When your program gets to a condition statement it checks to see whether a requirement is met before it moves forward.
The most commonly used control statements are if & else statements.
A good example of this is a program that checks for a valid pin number. If the user enters the right PIN number the program will let the user know that the PIN is right otherwise it will tell the user that the PIN is wrong.
This program checks if the statement following the if is true. If the value of the pinNumber variable is 9606 the program will do what is in the ‘if’ block, otherwise it will do what is in the else block.
If we combine else & if, it would work just like we would expect it to work
Let’s see an example that uses an ‘else if’ statement to check a person’s age range
When this program starts it checks to see if the age is less than 13, if it is then it prints Child and stops, if not it will jump to the next block, if the age is less than or equal to 19 then it will print Teenager, if not it will move on to the next block to check if age is under 65, if so it will print Adult, but if the conditions are met then the program will print Senior
Ex this program will check if two strings do not match
If the value of my variable is not ‘yo’ the program will print Not a match, otherwise the program will print Yo Match found.
2 > 4
3!=5 && !(3==5)