Control Structures

Home > Computer Science > Programming Languages > Control Structures

If-else statements, loops, switch statements, etc.

Conditional statements: These statements are used to execute a specific set of instructions based on the truth or falsehood of a particular condition.
Loops: Loops are used to repeat a specific set of instructions for a specific number of times or until a certain condition is met.
Switch statements: This is similar to the conditional statement but is used with multiple conditions rather than just a single one.
If/else statements: If/else statements are used to execute one block of instructions if a condition is met, and a different block of instructions if it's not.
Do/while loops: This type of loop is used to execute a block of instructions once, followed by a test condition that will determine if the loop should continue.
For loops: This type of loop is used to execute a set of instructions for a specific number of times, with the loop structure typically expressed as an integer iteration counter.
While loops: This type of loop is used to execute a block of instructions repeatedly, as long as a specific condition is met.
Control flow: This involves the sequence and order that statements are executed when running a program.
Nesting control structures: This involves combining multiple control structures in order to create more complex conditional logic or iterative processes.
Exception handling: This refers to the process of dealing with errors or exceptions that occur during program execution, which are typically related to issues like invalid input, file I/O or network connectivity.
Break, continue and goto statements: These statements allow you to change the order in which instructions are executed or to exit a loop entirely.
Recursion: Recursion is a process where a function calls itself in order to solve a particular problem or to execute a specific set of instructions.
Switch and case: This is similar to the conditional statement but is used with multiple conditions rather than just a single one.
Expression: This refers to the values or variables used in control structures to make decisions, perform calculations, or manipulate data.
Booleans: Booleans are a data type that can hold either true or false values, and are commonly used in conditional statements to help determine program flow.
iterative logic: This involves the use of loops to repeat certain portions of code, often with iterative program structures used to control the flow and logic of the code.
Use of libraries and modules: These are pre-built collections of code that can be easily imported and used to perform specific tasks or functions within larger programs.
Functional programming paradigms: These structures emphasize the use of functions and the flow of data throughout a program, as well as creating more robust and reusable code.
Object-oriented programming paradigms: These structures emphasize the use of objects, methods, and inheritance in creating more complex and reusable code.
Syntax: Finally, syntax refers to the specific rules and guidelines that programming languages use to define variables, types, and control structures, and is a key aspect of understanding and working effectively with these structures.
Conditional Statements: Conditional statements allow programmers to execute different actions based on whether a certain condition is true or false. Examples include if-else statements and switch-case statements.
Loops: Loops allow programmers to repeat a set of actions until a certain condition is met. Examples include for loops, while loops, and do-while loops.
Functions: Functions are reusable blocks of code that carry out a specific task. They allow programmers to modularize their code and make it more efficient.
Exception Handling: Exception handling allows programmers to manage errors or unexpected events that may occur during program execution. Examples include try-catch blocks and throw statements.
Subroutines: Subroutines are similar to functions but may not return a value. They allow programmers to break down complex tasks into smaller, more manageable components.
Iterators: Iterators allow programmers to traverse collections of data, such as arrays, lists, or sets. They provide a way to access and manipulate each element in the collection in a controlled manner.
Recursion: Recursion is a programming technique where a function calls itself until a certain condition is met. It can be an elegant solution to certain problems, but it can also be resource-intensive and lead to stack overflow errors.
Concurrency: Concurrency allows programmers to execute multiple tasks at the same time. This can be achieved through constructs such as threads, processes, coroutines, or asynchronous programming.
Generators: Generators are functions that can generate a sequence of values over time. They are often used to optimize memory usage or to perform lazy evaluation.
Macros: Macros are abstractions that allow programmers to define new syntax or shorthand for common tasks. They are often used in languages such as Lisp or C to create domain-specific languages.
"In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated."
"The emphasis on explicit control flow distinguishes an imperative programming language from a declarative programming language."
"Within an imperative programming language, a control flow statement is a statement that results in a choice being made as to which of two or more paths to follow."
"For non-strict functional languages, functions and language constructs exist to achieve the same result, but they are usually not termed control flow statements."
"A set of statements is in turn generally structured as a block, which in addition to grouping, also defines a lexical scope."
"Interrupts and signals are low-level mechanisms that can alter the flow of control in a way similar to a subroutine, but usually occur as a response to some external stimulus or event."
"At the level of machine language or assembly language, control flow instructions usually work by altering the program counter."
"For some central processing units (CPUs), the only control flow instructions available are conditional or unconditional branch instructions, also termed jumps."