Added exercise 4.28
[Cpp-Deitel-Exercises.git] / Chapter-4 / 4-28.cpp
blob7b21f6bf737f8bc039f581c7ced42bd12d5c4922
1 /*C++ How to Program, 9/E, by Paul Deitel & Harvey Deitel.
3 Solution of exercise 4.28:
4 (Checkerboard Pattern of Asterisks) Write a program that displays the
5 following checkerboard pattern. Your program must use only three output
6 statements, one of each of the following forms:
8 cout << "* ";
9 cout << ' ';
10 cout << endl;
12 * * * * * * * *
13 * * * * * * * *
14 * * * * * * * *
15 * * * * * * * *
16 * * * * * * * *
17 * * * * * * * *
18 * * * * * * * *
19 * * * * * * * *
21 Written by Juan Carlos Moreno (jcmhsoftware@gmail.com), 2023-02-12.*/
23 #include <iostream>
25 using namespace std;
27 int main()
29 int i, j;
31 for (i = 1; i <= 8; i++)
33 if ((i % 2) == 0)
35 cout << ' ';
37 for (j = 1; j <= 8; j++)
39 cout << "* ";
42 cout << endl;
45 return 0;