CS250Preparation, 2020

Preparing for CS250: Outline

Steven Zeil

1 Basics
1.1 Primitive Data Types and Assignments

What You Need to Know

Computers and Programming Languages

  • The programs used to manipulate and translate a C++ program: editor, preprocessor, compiler, linker, loader, IDE

  • The various stages or forms of a C++ program: source code, object code, executable program

Basic Elements of C++

  • The lexical (character level) elements of a C++ program: comments, special symbols, reserved words, identifiers, whitespace

  • The categories of C++ data types: simple (a.k.a. primitive), structured (a.k.a. compound), & pointers

  • The simple data types of C++: int, float, double, char, bool

  • How to declare variables

  • The basic operators of C++ and the syntax of expressions

  • Assignment statements

  • Simple I/O

Activities
  1. reading Read Malik, Chapter 1, “An Overview of Computers and Programming Languages”

  2. reading Read Malik, Chapter 2, "Basic Elements of C++.
    (If you are working from a different C++ textbook, you will have to figure out the corresponding chapters.)

  3. slides Commentary: Straight-Line Computation in C++

  4. selfassess Take the self-assessment: Primitive Data Types and Assignments (ungraded quiz)

1.2 I/O

What You Need to Know

  • Input and output streams.

    • The “standard” input (cin) and “standard” output (cout) streams.

  • Input

    • Reading data with >>

    • Reading data with get and getline

    • Determining the status of an input stream

  • Output

    • Output with <<

    • endl and \n

    • Formatting output (manipulators)

  • Reading and writing files

Activities
  1. reading Read Malik, Chapter 3, “Input/Output”

  2. slides Commentary: Input/Output (IO)

  3. lab Hands on: Basic C++ Projects in Code::Blocks

  4. selfassess Take the self-assessment: Input & Output (ungraded quiz)

1.3 Control Flow

What You Need to Know

  • The if and if else structure.
  • The conditional (?:) operator
  • Statement blocks ({})
  • The switch structure.
  • Loops
    • the while loop
    • the for loop
    • the dowhile loop
    • break and continue
  • The idea of simple versus compound statements.
  • Nesting of loops and conditional statements
Activities
  1. reading Read Malik, Chapters 4 and 5, “Control Structures”

  2. slides Commentary: Control Flow

  3. selfassess Take the self-assessment: Control Flow (ungraded quiz)

2 Function Calls and Parameter Passing

What You Need to Know

  • Calling common predefined functions (from <math>)
  • How to declare a function.
  • How to return an output from a function.
  • Return types, including void
  • Value, reference, and const reference parameters
    • Which to use for input, and which to use for output.
  • The scope of an identifier
    • the effects of { }
    • The scope of identifiers declared in for loop headers
    • “local” and “global” identifiers
  • Overloading of functions
  • Default parameter values
Activities
  1. reading Read Malik, Chapter 6, “User-Defined Functions”
  2. slides Commentary: Functions and Parameter passing
  3. selfassess Take the self-assessment: Function Calls & Parameter Passing (ungraded quiz)
  4. lab Hands on: Supplying Inputs to Programs

3 User-defined types

What You Need to Know

  • The enum type.
  • The typedef statement
  • The namespace
Activities
  1. reading Read Malik, Chapter 7, “User-Defined Simple Data Types, Namespaces, …”

  2. slides Commentary: User-Defined Types

4 Strings

What You Need to Know

  • The string type
  • The ‘.’ notation for calling string functions
  • Common string functions
    • Getting and changing individual characters
    • Concatenating (appending) strings
    • selecting substrings
    • searching and replacing within strings
  • String I/O
Activities
  1. reading Read Malik, Chapter 7, “…, and the string Type”

  2. slides Commentary: the std::string Class

  3. selfassess Take the self-assessment: Strings (ungraded quiz)
  4. lab Hands on: I/O, Control Flow, and Strings

5 Structuring Data
5.1 Basic Arrays

What You Need to Know

  • Declaring arrays (static)
  • Indexing into an array
  • Arrays and functions
    • passing arrays as parameters
      • The [] and * notation in parameters
    • dangers of returning arrays from functions
  • Common array processing
    • Reading and writing arrays
    • Searching an array
  • Multi-dimension arrays
  • Character arrays (a.k.a. “C strings”)
    • Null-terminated character arrays
    • Converting between character arrays and strings
Activities
  1. reading Read Malik, Chapter 8, “Arrays and Strings”
  2. slides Commentary: Basic Arrays
  3. lab Hands on: Project & Compiler Settings
  4. selfassess Take the self-assessment: Arrays (ungraded quiz)
5.2 Records (structs)

What You Need to Know

  • Declaring structs (a.k.a. “records”)
  • Accessing data members (a.k.a. “fields”) in a struct
  • Copying structs
  • structs and functions
    • passing structs as parameters
    • returning a struct
  • structs and arrays
Activities
  1. reading Read Malik, Chapter 9, “Records (structs)”
  2. slides Commentary: Records
  3. selfassess Take the self-assessment: Structs (ungraded quiz)
6 The Structure of a C++ Program

What You Need to Know

  • How C++ source code is divided into files

    • header files
    • compilation units
  • How a C++ compiler processes source code that has been divided.

    • The #include directive.
    • Other pre-processing commands
      • The use of #ifndef and #define in header files.
  • The difference between a declaration and a definition.

    • Dividing declarations and definitions among headers and compilation units.
Activities
  1. reading Read Re-read Malik, Chapter 1, “An Overview of Computers and Programming Languages”
  2. slides The Structure of a C++ Program
  3. lab Hands on: Multi-File Projects in Code::Blocks
7 The Pre-Test
Activities
  1. exam Take the exam: Take the pre-test.
Symbol Key
slides Commentary documents
text Textbook readings
lab Hands-On Activity

For instructors only