Conditional Statements
If you want to make something that can actually make a decision you need to use something called a conditional statement
Generally in the syntax of:
if(condition)
{
//code to execute
}
Inside of the parenthesis you have a conditional statement that is either true or false, and then inside of the curly braces is the code that executes whenever the given condition is rendered as true.
This is very nice because you could have your program make a decision based on a given set of circumstances, so you can choose what code runs where and when depending on the current state of your runtime.
Now you can compare two things using the == operator in mostly all programming languages, and you can then see this basically checks to see if one thing is equal to another thing, if we evaluate out to true, then the condition runs, if it is not true, the condition does not run.
You can also have something called the else statement:
if(condition)
{
//executes when condition is true
}
else
{
//runs when the condition is false
}
This is nice in case you want to make a branching decision based on the control flow of your program, if you want some code to run if something is happening, and then something else when it is not happening, then you can use the conditional statements just like this.
You can also invert the equal operator using the !=, there is also everything that you would have inside of propositional logic values inside of logic theory, this being negation: !, and: &&, or ||, as well as things like the equals ==, and then some languages even allow for the XOR: & like in c++.
There is also implications and what not of course, and as you can see that is basically exactly that the else/if statements are as