Conditional (computer programming)

conditionalif-then-elseconditional statementconditional statementsIFconditionalsif statementconditional branchingconditional expressionconditional expressions
In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language, which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false.wikipedia
264 Related Articles

Boolean data type

booleanBoolean variableBoolean value
In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language, which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false.
The Boolean data type is primarily associated with conditional statements, which allow different actions by changing control flow depending on whether a programmer-specified Boolean condition evaluates to true or false.

Structured programming

structuredProgram structurestructured program
As a result, structured programming, which allows (virtually) arbitrary statements to be put in statement blocks inside an statement, gained in popularity, until it became the norm even in most BASIC programming circles.
Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of the structured control flow constructs of selection (if/then/else) and repetition (while and for), block structures, and subroutines.

Imperative programming

imperativeimperative programming languageimperative language
In imperative programming languages, the term "conditional statement" is usually used, whereas in functional programming, the terms "conditional expression" or "conditional construct" are preferred, because these terms all have distinct meanings.
Conditional branching statements allow a sequence of statements to be executed only if some condition is met.

Dangling else

dangling else problemdangling-'''else
This is known as the dangling else problem, and is resolved in various ways, depending on the language.
The dangling else is a problem in computer programming in which an optional else clause in an if–then(–else) statement results in nested conditionals being ambiguous.

Statement (computer science)

statementstatementscompound statement
In imperative programming languages, the term "conditional statement" is usually used, whereas in functional programming, the terms "conditional expression" or "conditional construct" are preferred, because these terms all have distinct meanings.
For languages without call-by-name parameters the semantic description of a loop or conditional is usually beyond the capabilities of the language.

Lisp (programming language)

LispLisp programming languageLisp 1.5
In dialects of Lisp– Scheme, Racket and Common Lisp– the first of which was inspired to a great extent by ALGOL:
As one of the earliest programming languages, Lisp pioneered many ideas in computer science, including tree data structures, automatic storage management, dynamic typing, conditionals, higher-order functions, recursion, the self-hosting compiler, and the read–eval–print loop.

?:

ternary operator ?
C and C-like languages have a special ternary operator for conditional expressions with a function that may be described by a template like this:
In computer programming, is a ternary operator that is part of the syntax for basic conditional expressions in several programming languages.

Python (programming language)

PythonPython programming languagePython 2
Python uses the special keyword because structure is denoted by indentation rather than braces, so a repeated use of and would require increased indentation after every condition.

Ambiguous grammar

ambiguousunambiguousinherently ambiguous
A subtlety is that the optional else clause found in many languages means that the context-free grammar is ambiguous, since nested conditionals can be parsed in multiple ways.
In many languages, the in an If–then(–else) statement is optional, which results in nested conditionals having multiple ways of being recognized in terms of the context-free grammar.

Pattern matching

pattern-matchingpatternpatterns
Logic that would be expressed with conditionals in other languages is usually expressed with pattern matching in recursive functions.
Tree patterns are used in some programming languages as a general tool to process data based on its structure, e.g., C#, Rust, Swift, Haskell, ML, Scala and the symbolic mathematics language Mathematica have special syntax for expressing tree patterns and a language construct for conditional execution and value retrieval based on it.

Switch statement

switchcase statementCASE structure
If all terms in the sequence of conditionals are testing the value of a single expression (e.g., ... ... ...), then an alternative is the switch statement, also called case-statement or select-statement.
This functions as a generalized if–then–else conditional, here with any number of branches, not just two.

Arithmetic IF

3-way branch operationarithmetic'' IF
Because this arithmetic IF is equivalent to multiple statements that could jump to anywhere, it is considered to be an unstructured control statement, and should not be used if more structured statements can be used.
The arithmetic IF statement is a three-way arithmetic conditional statement, first seen in the first release of Fortran in 1957, and found in all later versions, and some other programming languages, such as FOCAL.

Bash (Unix shell)

BashBash shellBash script
Like all Unix shells, it supports filename globbing (wildcard matching), piping, here documents, command substitution, variables, and control structures for condition-testing and iteration.

QuickBASIC

Microsoft QuickBASICQuick BasicQuickBASIC 4.00
Later versions also added control structures, such as multiline conditional statements and loop blocks.

Test (Unix)

test
test is a command-line utility found in Unix-like operating systems that evaluates conditional expressions.

Ternary operation

ternary operatorternaryternary operators
C and C-like languages have a special ternary operator for conditional expressions with a function that may be described by a template like this:
Many programming languages that use C-like syntax feature a ternary operator, which defines a conditional expression.

Yoda conditions

In programming jargon, Yoda conditions (also called Yoda notation) is a programming style where the two parts of an expression are reversed from the typical order in a conditional statement.

Predication (computer architecture)

Branch predicationconditional movepredication
Apart from the case of branch predication, this is always achieved by selectively altering the control flow based on some condition.
Most computer programs contain conditional code, which will be executed only under specific conditions depending on factors that cannot be determined beforehand, for example depending on user input.

Branch (computer science)

branchconditional branchbranches
In high-level programming languages, branches usually take the form of conditional statements of various forms that encapsulate the instruction sequence that will be executed if the conditions are satisfied.

COBOL

Picture clauseCOBOL-85Named condition
COBOL's conditional statements are IF and EVALUATE.

Computer science

computer scientistcomputer sciencescomputer scientists
In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language, which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false.

Programming language

programming languageslanguagedialect
In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language, which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false.

Control flow

looploopscontrol structure
Apart from the case of branch predication, this is always achieved by selectively altering the control flow based on some condition.

Functional programming

functionalfunctional programming languagefunctional language
In imperative programming languages, the term "conditional statement" is usually used, whereas in functional programming, the terms "conditional expression" or "conditional construct" are preferred, because these terms all have distinct meanings.

Expression (computer science)

expressionexpressionsevaluation environment
In imperative programming languages, the term "conditional statement" is usually used, whereas in functional programming, the terms "conditional expression" or "conditional construct" are preferred, because these terms all have distinct meanings.