Control structures in C determine the flow of program execution. They include conditional statements, loops, and jump statements. Let's explore them!

Conditional Statements 🟢

if-else

if (condition) {
    // code if true
} else {
    // code if false
}

Use this for binary decisions.
👉 Learn more about conditional logic

switch-case

switch (expression) {
    case value1:
        // code
        break;
    case value2:
        // code
        break;
    default:
        // default code
}

Perfect for multiple discrete checks.
💡 Tip: Always use break to avoid fall-through!

Loops 🔁

for

for (init; condition; increment) {
    // loop body
}

Ideal for iterating with a clear start, condition, and step.
🐶 Example: for (int i=0; i<5; i++)See a visual example

while

while (condition) {
    // loop body
}

Executes as long as the condition is true.
⚠️ Beware of infinite loops!

do-while

do {
    // loop body
} while (condition);

Guarantees at least one execution.
📌 Compare all loop types

Jump Statements 🚀

break

Exits the nearest loop or switch.
🎮 Example: Stopping a game loop early

continue

Skips current iteration and proceeds to the next.
🔄 Useful for filtering loop elements

goto

Jumps to a labeled statement (not recommended for most use cases).
🚫 Avoiding goto pitfalls

decision tree

Visualizing control flow logic

switch statement

How switch evaluates cases

loop

Different loop structures comparison

flow control

Jump statements in action