CONSTANTS Function square Characters forming one line of a black Name Characters
ID: 3783688 • Letter: C
Question
CONSTANTS Function square Characters forming one line of a black Name Characters forming one line of a white square BLACK WHITE VARIABLES Description Data Type Name A row beginning with a white square whiteRow string A row beginning with a black square black Row string lfwe look carefullyat the chessboard, the algorithm jumps out at us. We to output five white five five whiteRows, five blackRows, five whiteRows, five blackRows, five whiteRows five blackRows. We can summarize this in our algorithm to output the five whiteRows and five blackRoe four times. Repeat four times Output five whiteRows Output five blackRows Chessboard program This program prints a chessboard pattern that is built up from basic strings of white and black characters. #include For cout, endl #include using namespace std; const string BLACK Define a line of a black square const string WHITE Define a line of a white square int main string white Row; A row beginning with a white square string blackRow A row beginning with a black square create a white-black row by concatenating the basic strings White Row WHITE BLACK WHITE BLACK WHITE BLACK WHITE BLACK; create a black-white row by concatenating the basic strings black Row BLACK WHITE BLACK WHITE BLACK WHITE BLACK WHITE:Explanation / Answer
To improve the Structure of the programme use function that print n number of rows
void PrintWhiteRow(int n) /* n represents the number of time to print the line*/
{
int i;
for(i=0;i<=n;i++) /* For loop is used to iterate the number of print statements
{
cout <<whiteRow << endl;
}
}
similarly use function PrintBlackRow to print n no of rows
void PrintBlackRow(int n) /* n represents the no of time to print the line*/
{
int i;
for(i=0;i<=n;i++)
{
cout <<blackRow << endl;
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.