C++ and Algorithmic Thinking for the Complete Beginner

Book description

Dive into the essentials of C++ and algorithmic thinking with this book. This comprehensive guide is perfect for newcomers looking to build a strong foundation in programming and problem-solving.

Key Features

  • Comprehensive introduction to C++ programming and detailed explanations of algorithmic concepts.
  • Step-by-step setup of development environments, with practical exercises and real-world examples.
  • In-depth coverage of control structures, and visual aids such as trace tables and flowcharts.

Book Description

Embark on your programming journey with a thorough introduction to how computers work, setting the stage for understanding C++ and its applications. This course begins with the basics, including setting up your development environment and installing necessary software packages. As you progress, you'll delve into fundamental algorithmic concepts, variables, constants, and handling input and output efficiently.

As you build your knowledge, the course introduces more complex topics such as sequence control structures, decision-making processes, and loop control structures. You will learn to manipulate numbers, strings, and understand the intricacies of operators through practical exercises and real-world examples. Visual aids like trace tables and flowcharts will help you visualize the flow of your programs and improve your debugging skills.

Towards the end of the course, you'll explore advanced topics such as arrays, data structures, subprograms, and an introduction to object-oriented programming. By the conclusion, you will also gain insights into file handling and advanced algorithmic strategies. Each chapter is designed to build on the previous one, ensuring a cohesive and comprehensive learning experience that equips you with the skills needed to excel in C++ programming and algorithmic thinking.

What you will learn

  • Understand how computers and programming languages work.
  • Master the basics of C++ and integrated development environments.
  • Develop and debug algorithms effectively.
  • Manipulate variables, constants, and data structures.
  • Implement control structures to manage program flow.
  • Create and use subprograms to optimize code.

Who this book is for

This course is designed for complete beginners with no prior programming experience, making it ideal for a wide range of learners. High school students, college students, and self-taught programmers will find this course particularly useful. It’s also suitable for professionals looking to transition into a programming role or enhance their technical skill set. Educators seeking a structured curriculum for teaching C++ can benefit from the course material. Basic computer literacy is recommended, but no prior knowledge of programming is required.

Table of contents

  1. Table of Contents
  2. Preface
    1. About the Author
    2. Acknowledgments
    3. How This Book is Organized
    4. Who Should Buy This Book?
    5. Conventions Used in This Book
    6. How to Report Errata
    7. Where to Download Material About this Book
    8. If you Like this Book
  3. Part I Introductory Knowledge
    1. Chapter 1 How a Computer Works
      1. 1.1 Introduction
      2. 1.2 What is Hardware?
      3. 1.3 What is Software?
      4. 1.4 How a Computer Executes (Runs) a Program
      5. 1.5 Compilers and Interpreters
      6. 1.6 What is Source Code?
      7. 1.7 Review Questions: True/False
      8. 1.8 Review Questions: Multiple Choice
    2. Chapter 2 C++ and Integrated Development Environments
      1. 2.1 What is C++?
      2. 2.2 What is the Difference Between a Script and a Program?
      3. 2.3 Why You Should Learn C++
      4. 2.4 How C++ Works
      5. 2.5 Boost C++ Libraries
      6. 2.6 Integrated Development Environments
      7. 2.7 Microsoft Visual Studio
    3. Chapter 3 Software Packages to Install
      1. 3.1 What to Install
    4. Review in “Introductory Knowledge”
      1. Review Crossword Puzzles
      2. Review Questions
  4. Part II Getting Started with C++
    1. Chapter 4 Introduction to Basic Algorithmic Concepts
      1. 4.1 What is an Algorithm?
      2. 4.2 The Algorithm for Making a Cup of Tea
      3. 4.3 Properties of an Algorithm
      4. 4.4 Okay About Algorithms. But What is a Computer Program Anyway?
      5. 4.5 The Three Parties!
      6. 4.6 The Three Main Stages Involved in Creating an Algorithm
      7. 4.7 Flowcharts
        1. Exercise 4.7-1 Finding the Average Value of Three Numbers
      8. 4.8 What are ”Reserved Words”?
      9. 4.9 What is the Difference Between a Statement and a Command?
      10. 4.10 What is Structured Programming?
      11. 4.11 The Three Fundamental Control Structures
        1. Exercise 4.11-1 Understanding Control Structures Using Flowcharts
      12. 4.12 Your First C++ Program
      13. 4.13 What is the Difference Between a Syntax Error, a Logic Error, and a Runtime Error?
      14. 4.14 What “Debugging” Means
      15. 4.15 Commenting Your Code
      16. 4.16 User-Friendly Programs
      17. 4.17 Review Questions: True/False
      18. 4.18 Review Questions: Multiple Choice
    2. Chapter 5 Variables and Constants
      1. 5.1 What is a Variable?
      2. 5.2 What is a Constant?
      3. 5.3 How Many Types of Variables and Constants Exist?
      4. 5.4 Rules and Conventions for Naming Variables and Constants in C++
      5. 5.5 What Does the Phrase “Declare a Variable” Mean?
      6. 5.6 How to Declare Variables in C++
      7. 5.7 How to Declare Constants in C++
      8. 5.8 Review Questions: True/False
      9. 5.9 Review Questions: Multiple Choice
      10. 5.10 Review Exercises
    3. Chapter 6 Handling Input and Output
      1. 6.1 How to Output Messages and Results to a User's Screen?
      2. 6.2 How to Output Special Characters?
      3. 6.3 How to Prompt the User to Enter Data?
      4. 6.4 Review Questions: True/False
      5. 6.5 Review Questions: Multiple Choice
    4. Chapter 7 Operators
      1. 7.1 The Value Assignment Operator
      2. 7.2 Arithmetic Operators
      3. 7.3 What is the Precedence of Arithmetic Operators?
      4. 7.4 Compound Assignment Operators
        1. Exercise 7.4-1 Which C++ Statements are Syntactically Correct?
        2. Exercise 7.4-2 Finding Variable Types
      5. 7.5 Incrementing/Decrementing Operators
      6. 7.6 String Operators
        1. Exercise 7.6-1 Concatenating Names
      7. 7.7 Review Questions: True/False
      8. 7.8 Review Questions: Multiple Choice
      9. 7.9 Review Exercises
    5. Chapter 8 Trace Tables
      1. 8.1 What is a Trace Table?
        1. Exercise 8.1-1 Creating a Trace Table
        2. Exercise 8.1-2 Creating a Trace Table
        3. Exercise 8.1-3 Swapping Values of Variables
        4. Exercise 8.1-4 Swapping Values of Variables – An Alternative Approach
      2. 8.2 Review Questions: True/False
      3. 8.3 Review Exercises
    6. Chapter 9 Using Visual Studio Community or Visual Studio Code
      1. 9.1 Write, Execute and Debug C++ Programs
    7. Review in “Getting Started with C++”
      1. Review Crossword Puzzles
      2. Review Questions
  5. Part III Sequence Control Structures
    1. Chapter 10 Introduction to Sequence Control Structures
      1. 10.1 What is the Sequence Control Structure?
        1. Exercise 10.1-1 Calculating the Area of a Rectangle
        2. Exercise 10.1-2 Calculating the Area of a Circle
        3. Exercise 10.1-3 Where is the Car? Calculating Distance Traveled
        4. Exercise 10.1-4 Kelvin to Fahrenheit
        5. Exercise 10.1-5 Calculating Sales Tax
        6. Exercise 10.1-6 Calculating a Sales Discount
        7. Exercise 10.1-7 Calculating a Sales Discount and Tax
      2. 10.2 Review Exercises
    2. Chapter 11 Manipulating Numbers
      1. 11.1 Introduction
      2. 11.2 Useful Mathematical Functions (Subprograms), and More
        1. Exercise 11.2-1 Calculating the Distance Between Two Points
        2. Exercise 11.2-2 How Far Did the Car Travel?
      3. 11.3 Review Questions: True/False
      4. 11.4 Review Questions: Multiple Choice
      5. 11.5 Review Exercises
    3. Chapter 12 Complex Mathematical Expressions
      1. 12.1 Writing Complex Mathematical Expressions
        1. Exercise 12.1-1 Representing Mathematical Expressions in C++
        2. Exercise 12.1-2 Writing a Mathematical Expression in C++
        3. Exercise 12.1-3 Writing a Complex Mathematical Expression in C++
      2. 12.2 Review Exercises
    4. Chapter 13 Exercises With a Quotient and a Remainder
      1. 13.1 Introduction
        1. Exercise 13.1-1 Calculating the Quotient and Remainder of Integer Division
        2. Exercise 13.1-2 Finding the Sum of Digits
        3. Exercise 13.1-3 Displaying an Elapsed Time
        4. Exercise 13.1-4 Reversing a Number
      2. 13.2 Review Exercises
    5. Chapter 14 Manipulating Strings
      1. 14.1 Introduction
      2. 14.2 The Position of a Character in a String
      3. 14.3 Useful String Functions/Methods (Subprograms), and More
        1. Exercise 14.3-1 Displaying a String Backwards
        2. Exercise 14.3-2 Switching the Order of Names
        3. Exercise 14.3-3 Creating a Login ID
        4. Exercise 14.3-4 Creating a Random Word
        5. Exercise 14.3-5 Finding the Sum of Digits
      4. 14.4 Review Questions: True/False
      5. 14.5 Review Questions: Multiple Choice
      6. 14.6 Review Exercises
    6. Review in “Sequence Control Structures”
      1. Review Crossword Puzzle
      2. Review Questions
  6. Part IV Decision Control Structures
    1. Chapter 15 Making Questions
      1. 15.1 Introduction
      2. 15.2 What is a Boolean Expression?
      3. 15.3 How to Write Simple Boolean Expressions
        1. Exercise 15.3-1 Filling in the Table
      4. 15.4 Logical Operators and Complex Boolean Expressions
        1. Exercise 15.4-1 Calculating the Results of Complex Boolean Expressions
      5. 15.5 Assigning the Result of a Boolean Expression to a Variable
      6. 15.6 What is the Order of Precedence of Logical Operators?
        1. Exercise 15.6-1 Filling in the Truth Table
        2. Exercise 15.6-2 Converting English Sentences to Boolean Expressions
      7. 15.7 What is the Order of Precedence of Arithmetic, Comparison, and Logical Operators?
      8. 15.8 How to Negate Boolean Expressions
        1. Exercise 15.8-1 Negating Boolean Expressions
      9. 15.9 Review Questions: True/False
      10. 15.10 Review Questions: Multiple Choice
      11. 15.11 Review Exercises
    2. Chapter 16 The Single-Alternative Decision Structure
      1. 16.1 The Single-Alternative Decision Structure
        1. Exercise 16.1-1 Trace Tables and Single-Alternative Decision Structures
        2. Exercise 16.1-2 The Absolute Value of a Number
      2. 16.2 Review Questions: True/False
      3. 16.3 Review Questions: Multiple Choice
      4. 16.4 Review Exercises
    3. Chapter 17 The Dual-Alternative Decision Structure
      1. 17.1 The Dual-Alternative Decision Structure
        1. Exercise 17.1-1 Finding the Output Message
        2. Exercise 17.1-2 Trace Tables and Dual-Alternative Decision Structures
        3. Exercise 17.1-3 Who is the Greatest?
        4. Exercise 17.1-4 Finding Odd and Even Numbers
        5. Exercise 17.1-5 Weekly Wages
      2. 17.2 Review Questions: True/False
      3. 17.3 Review Questions: Multiple Choice
      4. 17.4 Review Exercises
    4. Chapter 18 The Multiple-Alternative Decision Structure
      1. 18.1 The Multiple-Alternative Decision Structure
        1. Exercise 18.1-1 Trace Tables and Multiple-Alternative Decision Structures
        2. Exercise 18.1-2 Counting the Digits
      2. 18.2 Review Questions: True/False
      3. 18.3 Review Exercises
    5. Chapter 19 The Case Decision Structure
      1. 19.1 The Case Decision Structure
        1. Exercise 19.1-1 The Days of the Week
      2. 19.2 Review Questions: True/False
      3. 19.3 Review Exercises
    6. Chapter 20 Nested Decision Control Structures
      1. 20.1 What are Nested Decision Control Structures?
        1. Exercise 20.1-1 Trace Tables and Nested Decision Control Structures
        2. Exercise 20.1-2 Positive, Negative or Zero?
      2. 20.2 Review Questions: True/False
      3. 20.3 Review Exercises
    7. Chapter 21 More about Flowcharts with Decision Control Structures
      1. 21.1 Introduction
      2. 21.2 Converting C++ Programs to Flowcharts
        1. Exercise 21.2-1 Designing the Flowchart
        2. Exercise 21.2-2 Designing the Flowchart
        3. Exercise 21.2-3 Designing the Flowchart
      3. 21.3 A Mistake That You Will Probably Make!
      4. 21.4 Converting Flowcharts to C++ Programs
        1. Exercise 21.4-1 Writing the C++ Program
        2. Exercise 21.4-2 Writing the C++ Program
        3. Exercise 21.4-3 Writing the C++ Program
      5. 21.5 Review Exercises
    8. Chapter 22 Tips and Tricks with Decision Control Structures
      1. 22.1 Introduction
      2. 22.2 Choosing a Decision Control Structure
      3. 22.3 Streamlining the Decision Control Structure
        1. Exercise 22.3-1 “Shrinking” the Algorithm
        2. Exercise 22.3-2 “Shrinking” the C++ Program
        3. Exercise 22.3-3 “Shrinking” the Algorithm
      4. 22.4 Logical Operators – to Use, or not to Use: That is the Question!
        1. Exercise 22.4-1 Rewriting the Code
        2. Exercise 22.4-2 Rewriting the Code
      5. 22.5 Merging Two or More Single-Alternative Decision Structures
        1. Exercise 22.5-1 Merging the Decision Control Structures
        2. Exercise 22.5-2 Merging the Decision Control Structures
      6. 22.6 Replacing Two Single-Alternative Decision Structures with a Dual-Alternative One
        1. Exercise 22.6-1 “Merging” the Decision Control Structures
      7. 22.7 Put the Boolean Expressions Most Likely to be True First
        1. Exercise 22.7-1 Rearranging the Boolean Expressions
      8. 22.8 Why is Code Indentation so Important?
      9. 22.9 Review Questions: True/False
      10. 22.10 Review Questions: Multiple Choice
      11. 22.11 Review Exercises
    9. Chapter 23 More with Decision Control Structures
      1. 23.1 Simple Exercises with Decision Control Structures
        1. Exercise 23.1-1 Is it an Integer?
        2. Exercise 23.1-2 Validating Data Input and Finding Odd and Even Numbers
        3. Exercise 23.1-3 Where is the Tollkeeper?
        4. Exercise 23.1-4 The Most Scientific Calculator Ever!
        5. Exercise 23.1-5 Converting Gallons to Liters, and Vice Versa
        6. Exercise 23.1-6 Converting Gallons to Liters, and Vice Versa (with Data Validation)
      2. 23.2 Finding Minimum and Maximum Values with Decision Control Structures
        1. Exercise 23.2-1 Finding the Name of the Heaviest Person
      3. 23.3 Decision Control Structures in Solving Mathematical Problems
        1. Exercise 23.3-1 Finding the Value of y
        2. Exercise 23.3-2 Finding the Values of y
        3. Exercise 23.3-3 Solving the Linear Equation ax + b = 0
        4. Exercise 23.3-4 Solving the Quadratic Equation ax2 + bx + c = 0
      4. 23.4 Exercises with Series of Consecutive Ranges of Values
        1. Exercise 23.4-1 Calculating the Discount
        2. Exercise 23.4-2 Validating Data Input and Calculating the Discount
        3. Exercise 23.4-3 Sending a Parcel
        4. Exercise 23.4-4 Finding the Values of y
        5. Exercise 23.4-5 Progressive Rates and Electricity Consumption
        6. Exercise 23.4-6 Progressive Rates and Text Messaging Services
      5. 23.5 Exercises of a General Nature with Decision Control Structures
        1. Exercise 23.5-1 Finding a Leap Year
        2. Exercise 23.5-2 Displaying the Days of the Month
        3. Exercise 23.5-3 Checking for Proper Capitalization and Punctuation
        4. Exercise 23.5-4 Is the Number a Palindrome?
      6. 23.6 Boolean Expressions Reference and Handy Tips
      7. 23.7 Review Exercises
    10. Review in “Decision Control Structures”
      1. Review Crossword Puzzle
      2. Review Questions
  7. Part V Loop Control Structures
    1. Chapter 24 Introduction to Loop Control Structures
      1. 24.1 What is a Loop Control Structure?
      2. 24.2 From Sequence Control to Loop Control Structures
      3. 24.3 Review Questions: True/False
    2. Chapter 25 Pre-Test, Mid-Test and Post-Test Loop Structures
      1. 25.1 The Pre-Test Loop Structure
        1. Exercise 25.1-1 Designing the Flowchart and Counting the Total Number of Iterations
        2. Exercise 25.1-2 Counting the Total Number of Iterations
        3. Exercise 25.1-3 Counting the Total Number of Iterations
        4. Exercise 25.1-4 Counting the Total Number of Iterations
        5. Exercise 25.1-5 Finding the Sum of Four Numbers
        6. Exercise 25.1-6 Finding the Sum of Odd Numbers
        7. Exercise 25.1-7 Finding the Sum of N Numbers
        8. Exercise 25.1-8 Finding the Sum of an Unknown Quantity of Numbers
        9. Exercise 25.1-9 Finding the Product of 20 Numbers
      2. 25.2 The Post-Test Loop Structure
        1. Exercise 25.2-1 Designing the Flowchart and Counting the Total Number of Iterations
        2. Exercise 25.2-2 Counting the Total Number of Iterations
        3. Exercise 25.2-3 Designing the Flowchart and Counting the Total Number of Iterations
        4. Exercise 25.2-4 Counting the Total Number of Iterations
        5. Exercise 25.2-5 Finding the Product of N Numbers
      3. 25.3 The Mid-Test Loop Structure
        1. Exercise 25.3-1 Designing the Flowchart and Counting the Total Number of Iterations
      4. 25.4 Review Questions: True/False
      5. 25.5 Review Questions: Multiple Choice
      6. 25.6 Review Exercises
    3. Chapter 26 Definite Loops
      1. 26.1 The for statement
        1. Exercise 26.1-1 Creating the Trace Table
        2. Exercise 26.1-2 Creating the Trace Table
        3. Exercise 26.1-3 Counting the Total Number of Iterations
        4. Exercise 26.1-4 Finding the Sum of Four Numbers
        5. Exercise 26.1-5 Finding the Square Roots from 0 to N
        6. Exercise 26.1-6 Finding the Sum of 1 + 2 + 3 + … + 100
        7. Exercise 26.1-7 Finding the Product of 2 × 4 × 6 × 8 × 10
        8. Exercise 26.1-8 Finding the Sum of 22 + 42 + 62 + … (2N)2
        9. Exercise 26.1-9 Finding the Sum of 33 + 66 + 99 + … (3N)3N
        10. Exercise 26.1-10 Finding the Average Value of Positive Numbers
        11. Exercise 26.1-11 Counting the Vowels
      2. 26.2 Rules that Apply to For-Loops
        1. Exercise 26.2-1 Counting the Total Number of Iterations
        2. Exercise 26.2-2 Counting the Total Number of Iterations
        3. Exercise 26.2-3 Counting the Total Number of Iterations
        4. Exercise 26.2-4 Counting the Total Number of Iterations
        5. Exercise 26.2-5 Finding the Sum of N Numbers
      3. 26.3 Review Questions: True/False
      4. 26.4 Review Questions: Multiple Choice
      5. 26.5 Review Exercises
    4. Chapter 27 Nested Loop Control Structures
      1. 27.1 What is a Nested Loop?
        1. Exercise 27.1-1 Say “Hello Zeus”. Counting the Total Number of Iterations.
        2. Exercise 27.1-2 Creating the Trace Table
      2. 27.2 Rules that Apply to Nested Loops
        1. Exercise 27.2-1 Violating the First Rule
        2. Exercise 27.2-2 Violating the Second Rule
      3. 27.3 Review Questions: True/False
      4. 27.4 Review Questions: Multiple Choice
      5. 27.5 Review Exercises
    5. Chapter 28 More about Flowcharts with Loop Control Structures
      1. 28.1 Introduction
      2. 28.2 Converting C++ Programs to Flowcharts
        1. Exercise 28.2-1 Designing the Flowchart Fragment
        2. Exercise 28.2-2 Designing the Flowchart Fragment
        3. Exercise 28.2-3 Designing the Flowchart
        4. Exercise 28.2-4 Designing the Flowchart Fragment
        5. Exercise 28.2-5 Designing the Flowchart
      3. 28.3 Converting Flowcharts to C++ Programs
        1. Exercise 28.3-1 Writing the C++ Program
        2. Exercise 28.3-2 Writing the C++ Program
        3. Exercise 28.3-3 Writing the C++ Program
        4. Exercise 28.3-4 Writing the C++ Program
      4. 28.4 Review Exercises
    6. Chapter 29 Tips and Tricks with Loop Control Structures
      1. 29.1 Introduction
      2. 29.2 Choosing a Loop Control Structure
      3. 29.3 The “Ultimate” Rule
      4. 29.4 Breaking Out of a Loop
      5. 29.5 Cleaning Out Your Loops
        1. Exercise 29.5-1 Cleaning Out the Loop
        2. Exercise 29.5-2 Cleaning Out the Loop
      6. 29.6 Endless Loops and How to Stop Them
      7. 29.7 The “From Inner to Outer” Method
      8. 29.8 Review Questions: True/False
      9. 29.9 Review Questions: Multiple Choice
      10. 29.10 Review Exercises
    7. Chapter 30 More with Loop Control Structures
      1. 30.1 Simple Exercises with Loop Control Structures
        1. Exercise 30.1-1 Counting the Numbers According to Which is Greater
        2. Exercise 30.1-2 Counting the Numbers According to Their Digits
        3. Exercise 30.1-3 How Many Numbers Fit in a Sum
        4. Exercise 30.1-4 Finding the Total Number of Positive Integers
        5. Exercise 30.1-5 Iterating as Many Times as the User Wishes
        6. Exercise 30.1-6 Finding the Sum of the Digits
      2. 30.2 Exercises with Nested Loop Control Structures
        1. Exercise 30.2-1 Displaying all Three-Digit Integers that Contain a Given Digit
        2. Exercise 30.2-2 Displaying all Instances of a Specified Condition
      3. 30.3 Data Validation with Loop Control Structures
        1. Exercise 30.3-1 Finding Odd and Even Numbers - Validation Without Error Messages
        2. Exercise 30.3-2 Finding the Sum of Four Numbers
      4. 30.4 Finding Minimum and Maximum Values with Loop Control Structures
        1. Exercise 30.4-1 Validating and Finding the Minimum and the Maximum Value
        2. Exercise 30.4-2 Validating and Finding the Hottest Planet
        3. Exercise 30.4-3 ”Making the Grade”
      5. 30.5 Using Loop Control Structures to Solve Mathematical Problems
        1. Exercise 30.5-1 Calculating the Area of as Many Triangles as the User Wishes
        2. Exercise 30.5-2 Finding x and y
        3. Exercise 30.5-3 The Russian Multiplication Algorithm
        4. Exercise 30.5-4 Finding the Number of Divisors
        5. Exercise 30.5-5 Is the Number a Prime?
        6. Exercise 30.5-6 Finding all Prime Numbers from 1 to N
        7. Exercise 30.5-7 Heron's Square Root
        8. Exercise 30.5-8 Calculating π
        9. Exercise 30.5-9 Approximating a Real with a Fraction
      6. 30.6 Exercises of a General Nature with Loop Control Structures
        1. Exercise 30.6-1 Fahrenheit to Kelvin, from 0 to 100
        2. Exercise 30.6-2 Rice on a Chessboard
        3. Exercise 30.6-3 Just a Poll
        4. Exercise 30.6-4 Is the Message a Palindrome?
      7. 30.7 Review Questions: True/False
      8. 30.8 Review Exercises
    8. Review in “Loop Control Structures”
      1. Review Crossword Puzzle
      2. Review Questions
  8. Part VI Data Structures in C++
    1. Chapter 31 One-Dimensional Arrays and Maps
      1. 31.1 Introduction
      2. 31.2 What is an Array?
        1. Exercise 31.2-1 Designing an Array
        2. Exercise 31.2-2 Designing Arrays
        3. Exercise 31.2-3 Designing Arrays
      3. 31.3 Creating One-Dimensional Arrays in C++
      4. 31.4 How to Get Values from a One-Dimensional Array
        1. Exercise 31.4-1 Creating the Trace Table
        2. Exercise 31.4-2 Using a Non-Existing Index
      5. 31.5 How to Alter the Value of an Array Element
      6. 31.6 How to Iterate Through a One-Dimensional Array
        1. Exercise 31.6-1 Finding the Sum
      7. 31.7 How to Add User-Entered Values to a One-Dimensional Array
        1. Exercise 31.7-1 Displaying Words in Reverse Order
        2. Exercise 31.7-2 Displaying Positive Numbers in Reverse Order
        3. Exercise 31.7-3 Finding the Average Value
        4. Exercise 31.7-4 Displaying Reals Only
        5. Exercise 31.7-5 Displaying Elements with Odd-Numbered Indexes
        6. Exercise 31.7-6 Displaying Even Numbers in Odd–Numbered Index Positions
      8. 31.8 What is a Map?
      9. 31.9 Creating Unordered Maps in C++
      10. 31.10 How to Get a Value from an Unordered Map
        1. Exercise 31.10-1 Roman Numerals to Numbers
        2. Exercise 31.10-2 Using a Non-Existing Key in Unordered Maps
      11. 31.11 How to Alter the Value of a Map Element
        1. Exercise 31.11-1 Assigning a Value to a Non-Existing Key
      12. 31.12 How to Iterate Through a Map
      13. 31.13 Review Questions: True/False
      14. 31.14 Review Questions: Multiple Choice
      15. 31.15 Review Exercises
    2. Chapter 32 Two-Dimensional Arrays
      1. 32.1 Creating Two-Dimensional Arrays in C++
      2. 32.2 How to Get Values from Two-Dimensional Arrays
        1. Exercise 32.2-1 Creating the Trace Table
      3. 32.3 How to Iterate Through a Two-Dimensional Array
      4. 32.4 How to Add User-Entered Values to a Two-Dimensional Array
        1. Exercise 32.4-1 Displaying Reals Only
        2. Exercise 32.4-2 Displaying Odd Columns Only
      5. 32.5 What's the Story on Variables i and j?
      6. 32.6 Square Matrices
        1. Exercise 32.6-1 Finding the Sum of the Elements on the Main Diagonal
        2. Exercise 32.6-2 Finding the Sum of the Elements on the Antidiagonal
        3. Exercise 32.6-3 Filling in the Array
      7. 32.7 Review Questions: True/False
      8. 32.8 Review Questions: Multiple Choice
      9. 32.9 Review Exercises
    3. Chapter 33 Tips and Tricks with Data Structures
      1. 33.1 Introduction
      2. 33.2 Processing Each Row Individually
        1. Exercise 33.2-1 Finding the Average Value
      3. 33.3 Processing Each Column Individually
        1. Exercise 33.3-1 Finding the Average Value
      4. 33.4 How to Use More Than One Data Structures in a Program
        1. Exercise 33.4-1 Using Three One-Dimensional Arrays
        2. Exercise 33.4-2 Using a One-Dimensional Array Along with a Two-Dimensional Array
        3. Exercise 33.4-3 Using an Array Along with an Unordered Map
      5. 33.5 Creating a One-Dimensional Array from a Two-Dimensional Array
      6. 33.6 Creating a Two-Dimensional Array from a One-Dimensional Array
      7. 33.7 Useful Data Structures Functions/Methods (Subprograms)
      8. 33.8 Review Questions: True/False
      9. 33.9 Review Questions: Multiple Choice
      10. 33.10 Review Exercises
    4. Chapter 34 More with Data Structures
      1. 34.1 Simple Exercises with Arrays
        1. Exercise 34.1-1 Creating an Array that Contains the Average Values of its Neighboring Elements
        2. Exercise 34.1-2 Creating an Array with the Greatest Values
        3. Exercise 34.1-3 Merging One-Dimensional Arrays
        4. Exercise 34.1-4 Creating Two Arrays – Separating Positive from Negative Values
        5. Exercise 34.1-5 Creating an Array with Those who Contain Digit 5
      2. 34.2 Data Validation with Arrays
        1. Exercise 34.2-1 Displaying Odds in Reverse Order
      3. 34.3 Finding Minimum and Maximum Values in Arrays
        1. Exercise 34.3-1 Which Depth is the Greatest?
        2. Exercise 34.3-2 Which Lake is the Deepest?
        3. Exercise 34.3-3 Which Lake, in Which Country, Having Which Average Area, is the Deepest?
        4. Exercise 34.3-4 Which Students Have got the Greatest Grade?
        5. Exercise 34.3-5 Finding the Minimum Value of a Two-Dimensional Array
        6. Exercise 34.3-6 Finding the City with the Coldest Day
        7. Exercise 34.3-7 Finding the Minimum and the Maximum Value of Each Row
      4. 34.4 Sorting Arrays
        1. Exercise 34.4-1 The Bubble Sort Algorithm – Sorting One-Dimensional Arrays with Numeric Values
        2. Exercise 34.4-2 Sorting One-Dimensional Arrays with Alphanumeric Values
        3. Exercise 34.4-3 Sorting One-Dimensional Arrays While Preserving the Relationship with a Second Array
        4. Exercise 34.4-4 Sorting Last and First Names
        5. Exercise 34.4-5 Sorting a Two-Dimensional Array
        6. Exercise 34.4-6 The Modified Bubble Sort Algorithm – Sorting One-Dimensional Arrays
        7. Exercise 34.4-7 The Selection Sort Algorithm – Sorting One-Dimensional Arrays
        8. Exercise 34.4-8 Sorting One-Dimensional Arrays While Preserving the Relationship with a Second Array
        9. Exercise 34.4-9 The Insertion Sort Algorithm – Sorting One-Dimensional Arrays
        10. Exercise 34.4-10 The Three Worst Elapsed Times
      5. 34.5 Searching Elements in Data Structures
        1. Exercise 34.5-1 The Linear Search Algorithm – Searching in a One-Dimensional Array that may Contain the Same Value Multiple Times
        2. Exercise 34.5-2 Display the Last Names of All Those People Who Have the Same First Name
        3. Exercise 34.5-3 The Linear Search Algorithm – Searching in a Two-Dimensional Array that May Contain the Same Value Multiple Times
        4. Exercise 34.5-4 The Linear Search Algorithm – Searching in a One-Dimensional Array that Contains Unique Values
        5. Exercise 34.5-5 Searching for a Social Security Number
        6. Exercise 34.5-6 The Linear Search Algorithm – Searching in a Two-Dimensional Array that Contains Unique Values
        7. Exercise 34.5-7 Checking if a Value Exists in all Columns
        8. Exercise 34.5-8 The Binary Search Algorithm – Searching in a Sorted One-Dimensional Array
        9. Exercise 34.5-9 Display all the Historical Events for a Country
        10. Exercise 34.5-10 Searching in Each Column of a Two-Dimensional Array
      6. 34.6 Exercises of a General Nature with Data Structures
        1. Exercise 34.6-1 On Which Days was There a Possibility of Snow?
        2. Exercise 34.6-2 Was There Any Possibility of Snow?
        3. Exercise 34.6-3 In Which Cities was There a Possibility of Snow?
        4. Exercise 34.6-4 Display from Highest to Lowest Grades by Student, and in Alphabetical Order
        5. Exercise 34.6-5 Archery at the Summer Olympics
        6. Exercise 34.6-6 The Five Best Scorers
        7. Exercise 34.6-7 Counting the Frequency of Vowels
      7. 34.7 Review Questions: True/False
      8. 34.8 Review Exercises
    5. Review in “Data Structures in C++”
      1. Review Crossword Puzzle
      2. Review Questions
  9. Part VII Subprograms
    1. Chapter 35 Introduction to Subprograms
      1. 35.1 What Exactly is a Subprogram?
      2. 35.2 What is Procedural Programming?
      3. 35.3 What is Modular Programming?
      4. 35.4 Review Questions: True/False
    2. Chapter 36 User-Defined Subprograms
      1. 36.1 Subprograms that Return a Value
      2. 36.2 How to Make a Call to a Function
      3. 36.3 Subprograms that Return no Values
      4. 36.4 How to Make a Call to a void Function
      5. 36.5 Formal and Actual Arguments
      6. 36.6 How Does a Function Execute?
        1. Exercise 36.6-1 Back to Basics – Calculating the Sum of Two Numbers
        2. Exercise 36.6-2 Calculating the Sum of Two Numbers Using Fewer Lines of Code!
      7. 36.7 How Does a void Function Execute?
        1. Exercise 36.7-1 Back to Basics – Displaying the Absolute Value of a Number
      8. 36.8 Review Questions: True/False
      9. 36.9 Review Exercises
    3. Chapter 37 Tips and Tricks with Subprograms
      1. 37.1 Can Two Subprograms use Variables of the Same Name?
      2. 37.2 Can a Subprogram Call Another Subprogram?
      3. 37.3 Passing Arguments by Value and by Reference
      4. 37.4 Passing and/or Returning an Array
      5. 37.5 Default Argument Values (Optional Arguments)
      6. 37.6 The Scope of a Variable
      7. 37.7 Converting Parts of Code into Subprograms
      8. 37.8 Recursion
      9. 37.9 Review Questions: True/False
      10. 37.10 Review Exercises
    4. Chapter 38 More with Subprograms
      1. 38.1 Simple Exercises with Subprograms
        1. Exercise 38.1-1 A Simple Currency Converter
        2. Exercise 38.1-2 Finding the Average Values of Positive Integers
        3. Exercise 38.1-3 Finding the Sum of Odd Positive Integers
        4. Exercise 38.1-4 Finding the Values of y
      2. 38.2 Exercises of a General Nature with Subprograms
        1. Exercise 38.2-1 Validating Data Input Using a Subprogram
        2. Exercise 38.2-2 Sorting an Array Using a Subprogram
        3. Exercise 38.2-3 Progressive Rates and Electricity Consumption
        4. Exercise 38.2-4 Roll, Roll, Roll the… Dice!
        5. Exercise 38.2-5 How Many Times Does Each Number of the Dice Appear?
      3. 38.3 Review Exercises
    5. Review in “Subprograms”
      1. Review Crossword Puzzle
      2. Review Questions
  10. Part VIII Object-Oriented Programming
    1. Chapter 39 Introduction to Object-Oriented Programming
      1. 39.1 What is Object-Oriented Programming?
      2. 39.2 Classes and Objects in C++
      3. 39.3 The Constructor and the Keyword this
      4. 39.4 Passing Initial Values to the Constructor
        1. Exercise 39.4-1 Historical Events
      5. 39.5 Getter and Setter Methods
        1. Exercise 39.5-1 The Roman Numerals
      6. 39.6 Can a Method Call Another Method of the Same Class?
        1. Exercise 39.6-1 Doing Math
      7. 39.7 Class Inheritance
      8. 39.8 Review Questions: True/False
      9. 39.9 Review Exercises
    2. Review in “Object-Oriented Programming”
      1. Review Crossword Puzzle
      2. Review Questions
  11. Part IX Files
    1. Chapter 40 Introduction to Files
      1. 40.1 Introduction
      2. 40.2 Opening a File
      3. 40.3 Closing a File
      4. 40.4 Writing in (or Appending to) a File
      5. 40.5 The File Pointer
      6. 40.6 Reading from a File
      7. 40.7 Iterating Through the Contents of a File
      8. 40.8 Review Questions: True/False
      9. 40.9 Review Exercises
    2. Chapter 41 More with Files
      1. 41.1 Exercises of a General Nature with Files
        1. Exercise 41.1-1 Calculating the Sum of 10 Numbers
        2. Exercise 41.1-2 Calculating the Average Value of an Unknown Quantity of Numbers
        3. Exercise 41.1-3 Finding Minimum and Maximum Values
        4. Exercise 41.1-4 Concatenating Files
        5. Exercise 41.1-5 Searching in a File
        6. Exercise 41.1-6 Combining Files with Subprograms
      2. 41.2 Review Exercises
    3. Review in “Files”
      1. Review Crossword Puzzle
      2. Review Questions
  12. Some Final Words from the Author

Product information

  • Title: C++ and Algorithmic Thinking for the Complete Beginner
  • Author(s): Aristides Bouras
  • Release date: June 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781836208198