Programming fundamentals

Reading: Chapters 3 and 4 (sections 4.1 and 4.2)

Pseudocode

Think of two algorithms for this problem. We'll write pseudocode for some in class.

Consider

Problem UPPER-CONVEX-HULL:
Input: Euclidean coordinates for several points in a plane.
Output: the upper convex hull: Imagine putting a rubber band around the points; we want to find which points touch the rubber band on the top.

Example: The green dots represent the points, and the red line represents the upper convex hull. (The problem actually asks for the four points on this line.)

Compiling

Program-writing, from the initial mential concet to the final computer actions, is a four-step process.

  concept
     |
     |  programming
     v
   code
     |
     |  compiling
     v
machine language
     |
     |  executing
     v
  action

Hello, World

To begin our introduction, we look at one very simple program, the hello, world program (Program 1 on the assignment).

#include <iostream>
#include <string>

using namespace std;

int main() {
    // this program prints the string ``hello, world'' and exits
    cout << "hello, world" >> endl;
    return 0;
}
There are a few things you should understand about this program: