From 43938538ddf67089430f56660bf31c6b7e1c12c1 Mon Sep 17 00:00:00 2001 From: JCMH1981 Date: Tue, 21 Feb 2023 20:22:44 -0500 Subject: [PATCH] Added exercise 4.21 --- Chapter-4/4-21.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Chapter-4/4-21.cpp diff --git a/Chapter-4/4-21.cpp b/Chapter-4/4-21.cpp new file mode 100644 index 0000000..4c8df33 --- /dev/null +++ b/Chapter-4/4-21.cpp @@ -0,0 +1,37 @@ +/*C++ How to Program, 9/E, by Paul Deitel & Harvey Deitel. + +Solution of exercise 4.21: +// Exercise 4.21: ex04_21.cpp +// What does this program print? +#include +using namespace std; + +int main() +{ + unsigned int count = 1; // initialize count + + while ( count <= 10 ) // loop 10 times + { + // output line of text + cout << ( count % 2 ? "****" : "++++++++" ) << endl; + ++count; // increment count + } // end while +} // end main + +Written by Juan Carlos Moreno (jcmhsoftware@gmail.com), 2023-02-21.*/ + +#include + +using namespace std; + +int main() +{ + unsigned int count = 1; //Initialize count + + while ( count <= 10 ) //Loop 10 times + { + //Output line of text + cout << (count % 2 ? "****" : "++++++++") << endl; + ++count; //Increment count + } +} -- 2.11.4.GIT