// Homework #? // Problem 2.31 // Write a program that displays the following checkerboard pattern. #include main() { int row = 8, col; cout << "***** Solution using while loops *****\n\n"; while( row-- > 0 ) { col = 8; // Output a space if needed. if ( row % 2 == 0 ) { cout << ' '; } // Output asterik and space. while( col-- > 0 ) { cout << "* "; } cout << endl; } cout << "\n***** Solution using for loop *****\n\n"; for( int i=0; i<8; i++) { if ( i %2 ) cout << ' '; for( int j=0; j<8; j++) { cout << "* "; } cout << endl; } return 0; }