CHESSBOARD WITH LOOPS - for ( int i = 0; i<4;...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//CHESSBOARD WITH LOOPS //include required libraries #include <iostream> #include <string> //identify a scope for the identifiers using namespace std; //declare the required constants const string BLACK = "%%%%%%%%" ; // Define black square line const string WHITE = " " ; // Define white square line //main function call int main() { string whiteRow = "" ; // White square beginning row string blackRow = "" ; // Black square beginning row // Create a white-black row
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for ( int i = 0; i&lt;4; i++) { // Create a white-black row whiteRow += WHITE; whiteRow += BLACK; // Create a black-white row blackRow += BLACK; blackRow += WHITE; } for ( int j = 0; j&lt;5; j++) { for ( int i = 0; i&lt;5; i++) // Print five white-black rows cout &lt;&lt; whiteRow &lt;&lt; endl; for ( int i = 0; i&lt;5; i++) // Print five black-white rows cout &lt;&lt; blackRow &lt;&lt; endl; } return 0; }...
View Full Document

Ask a homework question - tutors are online