472,353 Members | 1,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Creating A Chessboard Program in C++

I have the idea to create the program but I need help in finishing it. My task is to write a program that prints out a chessboard using only asterisks. I have to use multiple nested loops with nested conditional statements inside. The output should look like a chessboard as follows: The pattern is not coming out as I want but I guess y'all know what a chessboard look like

* * * * *
* * * * *
* * * * *



* * * * *
* * * * *
* * * * *


int main()
{
for (int rowloop = 0; rowloop < 4; rowloop++)
{
for (int row = 0; row < 3; row++)
{
for (int column = 0; column < 5; column++)
cout << "*";
cout << endl;
}
cout << endl << endl;
}
return 0;
}

I want to have a variable for the box that way when I set up the row and column if it is odd it starts doing the pattern from the first location and if not it indent in like the second row in the example and print the pattern. I appreciate any help that I can get.
Nov 5 '06 #1
4 9096
vninja
40
i tried approaching this challenge a different way. first off i made this program write one line of the whole board x number times then made it rpt a couple of time (pardon the poor writing but its 5 in the morning and i'm dead tired (working) trying to get things to makes sense)

here is my program for creating the board. personally i would have used arrays and functions but this is taking off of what you had originally.



#include<iostream>
using namespace std;

int main()
{
int count = 0; // number for changing which row gets printed to screen in what
// pattern, change this to one to invert the pattern
for(int row = 0;row<6;row++) // number of rows in a chess board (might want to
{ // change that 6 to whatever you need)
if(count == 0)
{
for(int sqr=0;sqr<4;sqr++) // square size row wise how many * will be under
{ // each other
for(int col=0;col<6;col++)// <-- number of collumns in chess board divided by
{ // 2 (dark and light)
cout << " *****"; //<-- the output. if your square are going to be
} // squares make sure the num of * and spaces are
cout<<endl; // equivilant to the int number of variable sqr ^ above
}
}
else // when count switches this changes the output to the following
{
for(int sqr=0;sqr<4;sqr++)
{
for(int col=0;col<6;col++)
{
cout << "***** ";
}
cout<<endl;
}
}
count++;
if(count == 2)
count = 0; // keeps count 0 or 1
}
system("pause");

return 0;
}

sorry if this is comments are kind of long but i don't know what level of C++ you understand.
Nov 6 '06 #2
vninja
40
here is my output:

***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
***** ***** ***** ***** ***** *****
Nov 6 '06 #3
vninja
40
Here is my output (let me try again)
***** *****
***** *****
***** *****
***** *****
***** *****
***** *****
***** *****
***** *****
***** *****
***** *****
***** *****
***** *****
looks good on my post and on my screen but don't know if posting will cause formatting errors
Nov 6 '06 #4
Thank you so much for your response. I will try and run the program again tonight to see what happen and let you know.
Nov 6 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: asdasd | last post by:
Hello there, I'm hoping someone might be able to help me out. Its been awhile since I've programmed in visual basic (and roughly at that)... I...
2
by: Paul | last post by:
I am creating a Program for college, in which the Program will read a Folder and create a HTML page from the pictures that are storrd in that...
0
by: Paul | last post by:
I am creating a Program for college, in which the Program will read a Folder and create a HTML page from the pictures that are storrd in that...
0
by: Brian Mitchell | last post by:
Are there any good sites out there that show you how to make a modular program? For instance, I would like to create a program that accepts a...
3
by: Erik Foreman | last post by:
I am using a folderbrowserdialog object to prowse to a folder then once in that folder I am going to have my program rename all of the files in...
4
by: recruitor2001 | last post by:
Objective: To create a program that will allow the end user to input a number in terms of minutes and then click start. Once start has been selected...
1
by: satish100 | last post by:
how can i write a program for making the plain chessboard in PHP
2
by: hiimnath | last post by:
Hello all, i'm new to vb.net coding and programming and i'm making a program for my 4 year old brother that he has to type words and goes to the...
8
by: pazn16 | last post by:
I'm having trouble creating a program for this. I'am fairly new to C# so I don't really know exactly what to do. Create a C# program which prompts...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.