C++ Intermediate

Conditionals, while loops and nested-loop algorithms.

3 lessons 5 tasks ⚡ Live compiler
Lessons Compiler Quiz Certificate

📚 Lessons

1 Conditionals

Branch with if/else and combine tests with && / ||.

#include <iostream>
using namespace std;

int main() {
    for (int n = 1; n <= 5; n++) {
        if (n % 2 == 0) cout << n << " even" << endl;
        else cout << n << " odd" << endl;
    }
    return 0;
}

2 While loops

Use while when the iteration count depends on a condition rather than a fixed range.

#include <iostream>
using namespace std;

int main() {
    int n = 1, fib = 0, a = 0, b = 1;
    while (n <= 8) { fib = a + b; a = b; b = fib; n++; }
    cout << "8th term = " << a << endl;
    return 0;
}

3 Nested loops

Nested loops generate grids and tables — but two nested loops over n items is O(n²), so watch input size.

#include <iostream>
using namespace std;

int main() {
    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= 3; j++) cout << i * j << " ";
        cout << endl;
    }
    return 0;
}

⚡ C++ Compiler

Code runs on a learning-oriented simulated runtime that supports common constructs (output, variables, arithmetic, conditionals and loops).

CPP

            

📝 Tasks

5 tasks across 2 pages — multiple-choice and fill-in (type the answer). Score 70% or higher to earn your certificate.

🎓 Certificate of Completion

🔒 Pass the quiz above (70%+) to unlock your downloadable certificate.