Multiples of 2 with an Infinite Loop - C++ Statement

C++ examples for Statement:while

Description

Multiples of 2 with an Infinite Loop

Demo Code

#include <iostream>

int main(int argc, const char *argv[]) {
    int num = 2;//from   www .j  a  v  a  2 s .com

    while (true) {
        std::cout << num << std::endl;
        num *= 2;
        
        if( num > 400){
          break;
        }
    }

    return 0;
}

Result


Related Tutorials