General and Web Programming Fundamentals
  • Introduction
  • Program creation and design
    • Program design
      • Algorithms
      • Pseudocode
    • Programming conventions
    • Writing programs
      • Source code editors
      • Integrated Development Environments
      • Code repositories/Version control
      • Compilers/Interpreters
  • Programming Fundamentals
    • Operators
      • Arithmetic
      • Logical
      • Assignment
    • Constants and Variables
    • Datatypes
      • Primitive Datatypes
        • Character
        • Integer
        • Boolean
        • Floating point
        • Nothing (Null)
      • Composite Datatypes
        • Arrays
        • Strings
        • Classes
        • Structs
      • Literals
    • Data structures
      • Lists
      • Queues
      • Stacks
      • Map/dictionary
      • Trees
      • Graphs
    • Control structures
      • Selection (Conditional)
        • If/Else
        • Ternary
        • Switch
      • Iteration (Loops)
        • For loops
        • While loops
        • Do-While loops
        • For-Each loops
    • Functions
      • Parameters and arguments
      • Lambda expressions
      • Higher Order Functions
    • Space and Time
    • Scope
    • Standard libraries
  • Programming Paradigms
    • Procedural (Imperative) Programming
    • Object-oriented programming
    • Functional Programming
    • Declarative Programming
    • Event Driven programming
  • Programming Languages
    • Short history of programming
    • Low-level programming languages
    • High-level programming languages
  • Web Development
    • What is the web?
      • Web browsers (clients)
      • Webservers (serving web pages)
      • W3C
    • Markup languages
      • HTML
        • HTML Tags
      • Cascading Style Sheets (CSS)
        • CSS Properties
      • XML
      • Markdown
    • Scripting Languages
      • JavaScript
      • TypeScript
    • JSON
    • JavaScript Frameworks
  • Acknowledgements
    • About the author(s)
  • License
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Programming Fundamentals

Control structures

Control Structures in Computer Programming

Control structures are fundamental building blocks in computer programming, allowing developers to dictate the flow of execution within their programs. These structures can be categorized broadly into three types:

1. Sequential Control Structure

This is the default mode, where statements are executed one after the other in the order they are written. It's the simplest form of control flow, representing a straight-line path of execution.

2. Selection Control Structure

Selection (or conditional) control structures enable decision-making in programs. It allows the flow of execution to branch off in different directions based on conditions evaluated at runtime. The common selection structures include:

  • if statement

  • if-else statement

  • switch statement

3. Repetition Control Structure

Iteration/Repetition (or looping) control structures facilitate the execution of a block of code multiple times. They are crucial for tasks that require repetition such as iterating over arrays, processing items in a collection, or executing a block of code until a specific condition is met. Key repetition structures include:

  • for loop

  • while loop

  • do-while loop

Understanding and effectively applying these control structures is essential for creating efficient, readable, and maintainable code in any programming endeavor.

PreviousGraphsNextSelection (Conditional)

Last updated 1 year ago

Was this helpful?