Skip to content

Forever Loop

A forever loop is a loop that runs indefinitely, continuously executing the block of code unless explicitly interrupted or stopped.

c
while (1) {
    printf("This is an infinite loop in C\n");
}
c++
while (true) {
    cout << "This is an infinite loop in C++" << endl;
}
java
while (true) {
    System.out.println("This is an infinite loop in Java");
}
python
while True:
    print("This is an infinite loop in Python")