Home > Articles

C++ Control Statements, Part 2

Understand the essentials of counter-controlled iteration, use the for and do…while iteration statements, perform multiple selection using the switch selection statement, and use more C++20 text-formatting capabilities.

This chapter is from the book

4.1 Introduction

17 20 This chapter introduces the for, dowhile, switch, break and continue control statements. We explore the essentials of counter-controlled iteration. We use compound-interest calculations to begin investigating the issues of processing monetary amounts. First, we discuss the representational errors associated with floating-point types. We use a switch statement to count the number of A, B, C, D and F grade equivalents in a set of numeric grades. We show C++17’s enhancements that allow you to initialize one or more variables of the same type in the headers of if and switch statements. We discuss the logical operators, which enable you to combine simple conditions to form compound conditions. In our Objects-Natural case study, we continue using objects of preexisting classes with the miniz-cpp open-source library for creating and reading compressed ZIP archive files. Finally, we introduce more of C++20’s powerful and expressive text-formatting features.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.