Print Friendly and PDF
(Checkerboard Pattern of Asterisks) Write a program that displays the following checkerboard pattern. Your program must use only three output statements, one of each of the following forms: cout << "* "; cout << ' ' ; cout << endl; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
(Checkerboard Pattern of Asterisks) Write a program that displays the following checkerboard pattern. Your program must use only three output statements, one of each of the following forms:

cout << "* ";
cout << ' ' ;
cout << endl;


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


Solution:

#include<iostream>
#include
#include
using namespace std;
int main()
{
int column;
int row = 1;
while( row <= 8 ) {
column = 1;
while(column <= 16) {
if( ((column % 2 == 0) &amp; &amp; (row % 2 == 0) ) | | ((column % 2 == 1) &amp; &amp; (row % 2 == 1) ) ) {
cout << "*";
column++;
}

else
{

cout << " ";
column++;
}
}c
out << endl;
row++;
}/
/for pause
system("PAUSE") ;
return 0;
}
zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: