Control Structure in C language

Milan Kathiriya
3 min readDec 6, 2023

--

A control structure is a block of code that manages the flow of execution in a program.

Control structures dictate the order in which statements are executed based on certain conditions.

Types of control structures:

  1. Sequential Structure
  2. Selection Structure (Conditional Statements)
  3. Repetition Structure (Loops)

Let’s see each of them in brief:

Sequential Structure

  • The default structure is where statements are executed one after the other in sequence.
  • Example:
Sequential Structure

Selection Structure (Conditional Statements)

  • Allows the program to make decisions and execute different blocks of code based on specified conditions.
  • All conditional statements available in C language are mentioned below:
  1. if statement
  2. if else
  3. ladder
  4. nested
  5. ternary
  6. switch case
  • Let’s see the syntax of each of them:
Syntax of if statement
Syntax of if else statement
Syntax of a ladder if else statement
Syntax of a nested if else statement
Syntax of ternary conditional statement
Syntax of a switch case statement

Repetition Structure (Loops):

  • Allows the execution of a block of code repeatedly as long as a specified condition is true.
  • Types of loops in C language are mentioned below:
  1. Entry Controlled Loop: while loop, and for loop
  2. Exit Controlled Loop: do while loop
  • Let’s see the syntax of each of them:
Syntax of a while loop
Syntax of a do while loop
Syntax of for loop

Thanks for reading this article ❤️

If I got something wrong 🙈, Let me know in the comments. I would like to improve.

Clap 👏 If this article helps you. Add to your 📑 Reading list for future reference.

Connect with me on Linkedin and Github

--

--