C++ Question


Having Trouble Meeting Your Deadline?

Get your assignment on C++ Question  completed on time. avoid delay and – ORDER NOW


Create a C++ app that displays a checkerboard.

  • Prompt the user for the char to use for light squares.
  • Prompt the user for the char to use for dark squares.
  • Use a two-dimensional array of char to prepare the checkerboard.
  • Your checkerboard should be a square (test and submit with 8 rows and 8 cols).
  • Write a function that traverses the array and displays each element.
  • Call your function to produce a checkerboard similar to the sample output below.
  • Use colored text and/or colored backgrounds if you wish. Color output is not required, but nicely done color output will score an additional 5 points.
  • Thought question: why not ask the user how big to make the checkerboard?

What to Submit

Submit your completed .cpp file. If you used color, submit ansi_colors.h also.

Sample Output

This sample output shows what your checkerboard should look like with ‘X’ for dark squares and ‘O’ for light squares. Note that prompts for user input are not included in this sample output.

8x8 checkerboard with 'X' for dark squares, 'O' for light squares

Sample Color Output

If you want to play with color output, get the checkerboard pattern working and submit your assignment first!

You can display colored letters, or you can go for a graphical effect like the sample output below.


Each square in this checkerboard is a string that contains foreground and background color codes (from ansi_colors.h) plus two blanks. I used a string sa[8][8] array plus two std::stringstream variables to set this up. There are other, maybe better ways to get this same effect. I used stringstreams because they’re pretty easy to manage.

What’s a stringstream?

std::stringstreamLinks to an external site. is a C++ stream that works like cout and cin. Instead of streaming from/to the console like cin/cout, you can stream data into the stringstream and hold it for later use. A stringstream is bidirectional – you can also stream from the stringstream into a variable. Here’s a peek at how to use a stringstream for holding data:

    // Code to set up the stringstream
    std::stringstream ss_lite;
    // stream foreground and background color codes
    // plus two blank characters into the std::stringstream
    // variable ss_lite.
    ss_lite << FG_CYAN << BG_CYAN << "  ";

    // When you prepare the checkerboard array, 
    // store the stringstream's data in string array elements
    ac2d[row][col] = ss_lite.str();

Explanation & Answer

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Order Now and we will direct you to our Order Page at Litessays. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

Similar Posts