Conditional statement
Encyclopedia : C : CO : CON : Conditional statement
- This article is about a type of statement in computer programming; for conditional statements in general, see Logical conditional.
The most common is the If-Then clause:
If (condition) Then (statements) Else (statements) End IfIt works this way - when the computer finds an If (a reserved word), it waits for a data comparison, for example, x = 0 and evaluates the condition. If the condition is true, the statement block following the Then (another reserved word) shall be executed, otherwise the execution shall continue in the following statement block.
Depending on the language, the If may use Then, brackets, and another clause called Else or ElseIf.
There are many other conditional statements in programming languages, however, all of them follow these principles. Other conditional statements include switch statements, case statements and statements with guards.
See also
- Control flow#Choice
- Conditional branch for a theoretical view
- Pattern matching for another way to make execution choices
- Logical conditional for a more general view of conditionals
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
