is one of the most fundamental principles in programming
. Most programmers do it without thinking about it.
The great power of a computer program is not just to compute data, but to compute data in different ways depending on the qualities of the data. Conditional branching is about a program making decisions on the fly, based on the data its given.
All conditional statements - or conditionals - evaluate to either true or false. Once the evaluation has taken place, the computer performs the relevant action.
Consider this pseudocode (pseudocode isn't quite English, and it isn't quite a programming language - it's a way of expressing algorithms).
Get date from user.
If date = 25th of December
Print Hurrah, Christmas Day!
Print What a boring day!
See that? That's conditional branching. The program got data, and then it executed different instructions based on what the data was. If date = 25th of December evaluated to true, it printed a seasonal greeting. Otherwise, it printed "What a boring day!". You can see how much more useful this is than a program that executes the same instructions every time!
Common keywords used in conditional brancing are if and switch, along with their partners else and case.