CSCI 261 Programming Concepts (C++)

Winter/Spring 2012

Lecture Topics & Homework

Week 1: The Start of a Journey

Welcome to 261! The goal of this week is to dive in and compile your first program. The important concepts this week are to know how to compile and run a program with Visual Studio and how to define "constants" in code. We're also covering chapter 1 of our textbook.

Jan 11

Lecture 1: Introduction, Declaring Facts

Understand that real-world constants represent "facts that don't change," which become const declarations in C++. Know how to recognize a C++ "constant."

Homework due Jan 13:

  • Review all pages on this site (see the sidebar).
  • Make sure you can access this class on blackboard.
  • Enroll in this class on piazza (you should have received an email invitation).
  • Start reading Etter chapter 1

Jan 13

Lab 1: Hello World!

Learn how to compile and run a C++ program using Visual Studio. Recognize and modify constants. Learn how to properly submit all programming assignments.

Homework due Jan 16:

Week 2: Programming Fundamentals (Variables, Operators, Expressions)

Last week you learned that we can "teach the computer about facts in the world that don't change"; the keyword const; and how to compile and run a program in VS. The goal of this week is to introduce you to some basic syntax rules about C++, how to declare facts about the world that do change, and how to combine those facts with operators to create expressions. Your goal is at the end of this week is to enhance an existing graphical program such that it can successfully interpolate a value between two points of data. The important concepts this week are to know how to declare and use variables and expressions. We're also covering chapter 2 of our textbook.

Jan 16

Lecture 2: Compilation Process, Program Anatomy, Intro to Variables, Expressions & I/O

Understand how "code" becomes programs through compilation, linking and execution (what happens when you hit ctrl-F5). Grasp the general anatomy of simple C++ programs. Learn how variables are used to declare "facts that may change" and learn what cin and cout do.

Homework due Jan 18:

Jan 18

Lecture 3: C++ Fundamentals

Today you will learn about some basic C++ syntax rules. Understand how to declare variables using proper syntax. Learn about primitive operators such as addition and multiplication. Learn how to combine operators and variables to form expressions.

Homework due Jan 20:

Jan 20

Lab 2: Linear Interpolation

Exercise what you've learned this week by improving a graphical program that calculates an interpolated value between two points of data. This is a useful skill for many engineering contexts.

Homework due Jan 23:

Week 3: Making Decisions (Boolean logic and Selection Statements)

Now that you've learned how to teach the computer about simple facts in the world and exercised some basic C++ syntax, it's time to do something more useful: teaching the computer how to make decisions, given what it understands about the world. Your goal at the end of this week is to implement a game of Rock, Scissors, Paper. The important concepts this week are to understand that boolean expressions get evaluated and yield a value and how to use selection statements to model logical decision-making. We're also covering 3.1 and 3.2 of our book.

Note: be sure to download this week's assignment pack.

Jan 23

Lecture 4: Boolean Logic

First, review operations with mixed types: it seems trivial but it's something that all programmers tend to overlook. Next, learn about the life and death of George Boole, it's a sad story (yet somehow we'll laugh, in honor of his great work of course). Learn about boolean logic and how any decision can, in theory, be reduced to a Boolean expression. Learn about truth tables, logical expressions and how true and false are representations of 0 and 1.

Homework due Jan 25:

Jan 25

Lecture 5: Selection Statements

Today you will learn about how to teach the machine to make decisions based on Boolean logic. Understand how to use selection statements with if, else if and else. Learn how to model more complex decisions with nested selection statements, and exercise your understanding of how computers represent character data.

Homework due Jan 27:

Jan 27

Lab 3: Rock, Paper, Scissors: Fight!

Exercise what you've learned this week by creating a simple console-based game of Rock, Paper Scissors. This assignment tests your ability to implement more complicated logic, your understanding of how computers handle character data, and how to use pseudocode to help guide your program development.

Homework due Jan 30:

Week 4: Doing Things Repeatedly (loops with while and for)

Recall what we said about computers being very good at doing repetitive tasks. This week you will learn how to tell the computer to do things repeatedly, and how to modify what the computer does during each repetition. The important concepts this week are to understand common loop "patterns," and how to use C++ loop syntax to model repetitive tasks. We're also covering sections 3.4 and 3.5 of our book.

Don't forget to download this week's assignment pack.

Jan 30

Lecture 6: Loops with while

Today you will learn about how to teach the machine to complete repetitive tasks, which computers are incredibly good at doing. Today you will learn to think about "stopping conditions" and how to modify each task repetition. Understand how to implement loops with while and recognize common looping patterns.

Homework due Feb 1:

Feb 1

Lecture 7: Loops with for and Intro to Machine Randomness

Another useful tool for implementing repetitive tasks is the for loop. Learn about the similarities between while and for loops and how to convert a while loop to a for loop (and vice-versa). Excercise your understanding of loops with a more challenging version of the previous assignment. Learn about pseudo-random numbers and how to use rand().

Homework due Feb 3 Feb 6:

Feb 3

Lab 4: Number Guessing Snow Day! No Class.

Exercise what you've learned over the past two weeks by creating every aspiring game programmer's first game: guess-the-number. Don't be fooled, it's not as simple as you might think. Exercise using rand() and both loops and selection statements together.

Homework due Feb 6 Feb 10:

Week 5: Data, Input/Output

You've learned how a program can be "interactive" by accepting keyboard input and printing information to the screen. This week you will take a first step toward automation and persistence, creating programs that can read lots of data from files and write data to files. Think of how the data "outlives" the execution of the program. The important concepts this week are how to read and write data. We're also covering sections 4.2 and 4.5 of our book.

Don't forget to download this week's assignment pack.

Feb 6

Lecture 8: Reading Data

You've learned how to provide the machine information interactively via the keyboard. But what if you need to provide a machine lots of information? How does a program like iTunes read an .mp3 file and generate music? Today you will learn how to create programs that can read data from text files and act upon that data.

Homework due Feb 8:

Feb 8

Lecture 9: File I/O in Detail, Writing Data

Have you ever thought about how the information your programs print to the screen just "disappear" once the program ends? What if you wanted to "keep" the output from your program around for later use? We call this "data persistence," in its most simple form. Now that you've learned how to read data, today you will create a program that writes information to a text file.

Homework due Feb 10:

Feb 10

Lab 5: Simple Stats

Now that you've learned how to read and write data, consider how much of the data we see is presented in a tabular format of rows and columns. Rather than process each piece of data individually, you often need to extract multiple pieces of data in one "row." Learn how to chain the >> operator with your loops to act upon rows of data.

Homework due Feb 13:

Week 6: Abstraction, Encapsulation and Functions

You have now learned about the fundamental concepts needed to write useful programs. This week you will begin to learn about a key abstraction in programming: the function. Think of how meaningful function names help your programs read more like human language, and how functions are like "mini programs" that abstract the work that they do, letting you focus on how to use them, not how they do their work. The important concepts this week are how to use and define functions; and what "scope" is all about. We're also covering part of chapter 5 of our book.

Don't forget to download this week's assignment pack.

Feb 13

Lecture 10: Functions

You've learned the nuts and bolts of programming, now learn about how to combine those nuts and bolts into more effective, readable, maintainable programs. Today you will learn about what functions are, how to use them and how to define them.

Homework due Feb 15:

Feb 15

Lecture 11: More FUNctions

Getting our heads around functions takes time and practice. Today we will practice defining and calling functions, discuss more about parameters and arguments, how arguments are passed by value, and what this thing called "scope" is all about. You will also learn about how to use function prototypes above main and definitions below.

Homework due Feb 17:

  • 15_robot
  • Continue reading Etter 5.1 - 5.3 (p198)

Feb 17

Lab 6: Mines Dating Diary

Exercise your ability to design functions that are reusable. In this lab you will create a program that records your very busy dating history here at Mines. You will use functions to abstract away low-level "busy work," resulting in a main() program that is easy to read (even for your programming date).

Homework due Feb 20 Feb 22:

Week 7: Functions, Libraries and a Taste of Recursion

You have now begun to learn about how functions allow you to write a bit of code once and re-use it. You have also seen how functions result in more readable programs, and how using libraries built by others allows you to write productive programs. This week we will be continuing our practice with defining and using functions, and we will end with a brain-bender: functions that call themselves. The important concepts this week are scope, more function definitions and use, and recursion. We will also begin preparing for the midterm exam.

No class on Feb 20. Yay!

Feb 22

Lecture 12: Functions and Scope

It takes time to get comfortable with parameters vs. arguments and to gain an understanding of function "scope." Today you will learn about "global" scope vs. "local" scope and a common use of global variables: to declare constants that multiple functions may need to use. In addition, we will be practicing more with functions and begin to test your knowledge with questions similar to what you can expect on the midterm exam.

Homework due Feb 24:

Feb 24

Lab 7: Function Review

The lab topic is being revised to accommodate the short week.

Homework due Feb 27:

  • 17b_ (being revised, stay tuned)