PIC 10A: Introduction to Programming
About
This course teaches the fundamentals of programming in C++. The course is titled "Introduction To Programming" because from the 1980s until 2026, this course was the first in the sequence and students needed to take it before any of the others. However, as the "Plan Your Courses" page explains carefully, the times they are a-changin, and from 2027 onwards, there is a Python-centric track available to PIC students that begins with PIC 1.
C++ was developed in the 1980s, but it is still used extensively today and it remains one of the world's most popular programming languages. C++ is used by operating systems, web browsers, and in game development. C++ is used in medical devices, robotics, and financial systems. In AI and machine learning infrastructure, useful Python libraries are often written in C++ for speed. C++ serves as the foundational backbone for infrastructure where raw performance, low latency, and direct hardware control are mandatory.
From an educational point of view, learning C++ is useful because many fundamental concepts (data types and memory management, for example) are addressed explicitly by the language. Even if most applications that interest you are best served by other languages, knowing C++ can improve your understanding of programming so that these other languages are easier and quicker to learn, and so that you can better appreciate the advantages and disadvantages of different languages for solving different problems.
PIC 10A covers a lot of ground. Upon completion of the class, a student will be familiar with variables, control flow, functions, console input/output, pointers, references, and classes (object oriented programming). Students who complete this course will be well prepared for more advanced courses about C++ as well as PIC courses in other programming languages. An ambitious and imaginative student will already be able to implement their own interesting applications in C++.
Course Description
Lecture, three hours; discussion, two hours. No prior programming experience assumed. Basic principles of programming in C++; algorithmic, procedural problem solving; variables, assignment, fundamental types (int, double, char, bool, size_t, etc.), casting; standard input and output streams; control flow; functions, function overloading, references; the string class, the vector class, programmer-defined structs and classes, constructor initializer lists; const correctness; C-style arrays, pointers; integrated development environments, source code organization, code documentation. P/NP or letter grading.
Learning Outcomes / Course Objectives / Core Competencies
After successful completion of PIC 10A, students should be able to...
- Explain the difference between a compile-time error, a run-time error, and undefined behavior.
- Choose the appropriate fundamental type for a given context.
- Recall that doubles have limited precision and cannot perform fraction arithmetic perfectly.
- Use the standard input and output streams.
- Use the string and vector classes.
- Implement, test, and debug short algorithms involving nested control flow.
- Describe the difference between defining a function and calling a function and how the arguments in a function call are connected to the parameters in its definition.
- Predict code output for code involving control flow, vectors, and calls to functions which pass their arguments by value and/or by reference.
- Choose when to pass function arguments by value, by reference, and/or by reference to const.
- Analyze short programs involving functions to determine what the code is doing, to identify any errors the code has, and to correct the errors that are found.
- Create short classes from scratch, writing constructors using constructor initializer lists.
- Predict code output for code involving a class using another class and constructors which identify themselves with print statements.
- Justify decisions regarding the accessibility (public or private) of class members.
- Write code that adheres to const correctness and identify errors that result from misusing const.
- Use pointers to pass C-style arrays to functions.
- Use multiple header and cpp files in one project.
General Course Outline / Schedule of Lectures
Lectures 1-4
- Hello world, cout
-
Errors
- build errors
- runtime errors
- undefined behavior
- other errors
- Variables, assignment, and simple uses of cin >> variable
-
Fundamental types
- ints, doubles, arithmetic
- chars, bools, comparison operators
- casting using static_cast
- Examples demonstrating that doubles have limited precision
- Mathematical functions, e.g. pow and sqrt
- The const keyword
Lectures 5-12
-
The string class
- indexing with operator[] and at
- length, substr, push_back, pop_back
- find, rfind, size_t's
- concatenation
-
Control flow
- if
- while
- for
-
cin and the input buffer
- cin >> variable
- getline(cin, s)
- cin.ignore(), cin.get(), cin.peek()
- Vectors
Lectures 13-18
-
Functions
- function signatures, function comments
- function definitions
- the void keyword
- the return keyword
- pure functions and procedures
- parameters and arguments
-
References
- independently from functions
- in an application which mutates an argument to a function call, e.g. swapping two ints
- in an application which avoids copying large amounts of data, e.g. printing a vector
-
Const correctness
- when to pass by value
- when to pass by reference
- when to pass by reference to const
- Source code organization, i.e. what goes in a header file and what goes in a cpp file
- Overloading functions
Lectures 19-24
-
Structs
- struct interfaces
- member variables and member functions
- the member access operator and the scoping operator
- constructors and constructor initializer lists
- const correctness for member functions
- The public and private keywords, and classes
- Default values
- for functions
- for member functions
- source code organization
Lectures 25-26
- C-style arrays
- Pointers (but no memory allocation)
- Pointer arithmetic
- Passing C-style arrays to functions by decaying them to pointers
Lectures 27-28
On topics of the instructors choice. Some suggestions are…
- Range-based for loops
- Sets, unordered sets, other data structures
- Iterators
- String streams
- File streams
Expected Grade Scheme and Homework Assignments
- Homework: 15%
- Midterm 1: 25%
- Midterm 2: 25%
- Final: 35%
Since this is an introductory class in which students often rely on homework assignments to reinforce their lecture learning in a timely manner, PIC 10A instructors are required to assign at least five homework assignments.