0
0
C++programming~20 mins

Continue statement in C++ - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Continue Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of loop with continue
What is the output of the following C++ code?
C++
#include <iostream>
int main() {
    for (int i = 1; i <= 5; i++) {
        if (i == 3) continue;
        std::cout << i << " ";
    }
    return 0;
}
A1 2 4 5
B2 3 4 5
C1 2 3 4
D1 2 3 4 5
Attempts:
2 left
💡 Hint
The continue statement skips the rest of the loop body for the current iteration.
Predict Output
intermediate
2:00remaining
Sum with continue skipping multiples of 4
What is the value of sum after running this code?
C++
#include <iostream>
int main() {
    int sum = 0;
    for (int i = 1; i <= 10; i++) {
        if (i % 4 == 0) continue;
        sum += i;
    }
    std::cout << sum;
    return 0;
}
A43
B50
C40
D55
Attempts:
2 left
💡 Hint
Numbers divisible by 4 are skipped and not added to sum.
Predict Output
advanced
2:00remaining
Nested loops with continue
What is the output of this nested loop code?
C++
#include <iostream>
int main() {
    for (int i = 1; i <= 3; i++) {
        for (int j = 1; j <= 3; j++) {
            if (j == 2) continue;
            std::cout << i << j << " ";
        }
    }
    return 0;
}
A12 22 32
B11 12 13 21 22 23 31 32 33
C11 13 22 23 31 33
D11 13 21 23 31 33
Attempts:
2 left
💡 Hint
The continue skips printing when j equals 2 inside inner loop.
Predict Output
advanced
2:00remaining
Continue in while loop
What is the output of this code?
C++
#include <iostream>
int main() {
    int i = 0;
    while (i < 5) {
        i++;
        if (i == 3) continue;
        std::cout << i << " ";
    }
    return 0;
}
A1 2 3 4 5
B1 2 4 5
C2 3 4 5
D1 2 3 4
Attempts:
2 left
💡 Hint
The continue skips printing when i equals 3 after increment.
🧠 Conceptual
expert
2:00remaining
Effect of continue on loop variable increment
Consider this code snippet. What will be the output?
C++
#include <iostream>
int main() {
    for (int i = 0; i < 5; ) {
        i++;
        if (i == 3) continue;
        std::cout << i << " ";
    }
    return 0;
}
A1 2 3 4 5
B1 2 3 4
C1 2 4 5
D2 3 4 5
Attempts:
2 left
💡 Hint
The increment is inside the loop body before continue.