From a3d223df0662c85b3c88708fb31be5bef4b66713 Mon Sep 17 00:00:00 2001 From: JCMH1981 Date: Sun, 12 Mar 2023 18:34:35 -0500 Subject: [PATCH] Added exercise 4.28 --- Chapter-4/4-28.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Chapter-4/4-28.cpp diff --git a/Chapter-4/4-28.cpp b/Chapter-4/4-28.cpp new file mode 100644 index 0000000..7b21f6b --- /dev/null +++ b/Chapter-4/4-28.cpp @@ -0,0 +1,46 @@ +/*C++ How to Program, 9/E, by Paul Deitel & Harvey Deitel. + +Solution of exercise 4.28: +(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; + + * * * * * * * * + * * * * * * * * + * * * * * * * * + * * * * * * * * + * * * * * * * * + * * * * * * * * + * * * * * * * * + * * * * * * * * + +Written by Juan Carlos Moreno (jcmhsoftware@gmail.com), 2023-02-12.*/ + +#include + +using namespace std; + +int main() +{ + int i, j; + + for (i = 1; i <= 8; i++) + { + if ((i % 2) == 0) + { + cout << ' '; + } + for (j = 1; j <= 8; j++) + { + cout << "* "; + } + + cout << endl; + } + + return 0; +} -- 2.11.4.GIT