Nested Conditionals & C++17 Initializers

🟡 Intermediate

📖 Definition

Nested conditionals place if statements inside other if blocks for hierarchical decisions. C++17 allows scoped initializers inside if statements (if (init; condition)).

💡 Code Example

#include <iostream>

int main() {
    int x = 10;
    if (x > 0) {
        if (x % 2 == 0) {
            std::cout << "Positive Even Number\n";
        }
    }

    // C++17 if with initializer
    if (int val = 42; val > 0) {
        std::cout << "C++17 Initializer val: " << val << "\n";
    }
    return 0;
}