Print Checkerboard Patter of Asterisks - C++ Statement

C++ examples for Statement:for

Description

Print Checkerboard Patter of Asterisks

Demo Code

#include <iostream>

int main(int argc, const char *argv[]) {
    for (int i = 1; i <= 8; i++) {
        if (i % 2 == 0) {
            std::cout << ' ';
        }//from  w w  w . j a va  2s. co  m
        for (int j = 0; j < 8; j++) {
            std::cout << "* ";
        }
        std::cout << std::endl;
    }
    return 0;
}

Result


Related Tutorials