Handouts

There were 5 handouts:

It is strongly suggested that you read these by Monday. If you were unable to get one of the first four handouts during class, they are available on the PUBLIC fileserver at: PUBLIC -> Courses & Support -> Academic Departments & Courses -> Computer Science -> CS 5 -> Handouts. The Short assignment is in the CS 5 folder in the folder titled "Short Assignments".

Key Ideas

The Key ideas I plan to cover in this course are:

Programming is more than just making computers do things. It's a whole new way of thinking, and it will come naturally to some of you, and not so easily to others. Use the course staff as a resource, and ask questions.

There are stupid questions, however. These include ones such as:

"When are your office hours?"
"Can I get an extension on the assignment due today?"

The answers to these, and many other stupid questions are included in the handouts.

Factorial Example

There are four examples of a program that can be used to output 5!. These examples are available on Public, in the CS 5 folder, in the Class Examples folder.

n!, or n factorial, is defined as:

The first example, fact0.cpp only prints out 120. There are several problems with this, but one huge one is that we must already know the answer to the problem before we write the program.

This is fixed in fact1.cpp, which first uses the definition of factorials to compute the answer, and then prints it out. However, this program is not general enough. If we write programs following this model, then 8! requires a whole new program to compute.

We can fix this by waiting for the use to enter the number of which he wishes to find the factorial, as we have in fact2.cpp. Now, however, a new problem arises - what if the user forgets what the program does?

The answer is to prompt the user, as fact3.cpp does. This version also has the added feature of comments in the source code. Those are the lines which begin with a double slash (//) and they are ignored by the compiler. What they do is to explain to the person reading the source code what the program does.

Elements of a good program

The factorial example shows some characteristics of good programs, and why they are useful. We will cover these more in depth later:

To Index Next