Activity 1-1 - Introduction



In this course you will learn to write C++ programs to solve different problems.  From time-to-time this task may become frustrating and difficult.  However, with patience and practice, you will gain more experience and things will get easier.  The difficulty in using a computer to solve problems comes from the fact that you need to somehow ask a computer to do things for you.  Imagine, sitting in front of the computer and asking her to add two numbers,  “Hey you add 2 to 4 and tell me what the answer is.”  But we do not normally talk directly to a computer, not yet. Instead, we communicate with it through an operating system (OS).  The communication with OS is done via the program that you write.  Our program is a set of instructions that a computer will follow.  These instructions are not in English but we understand them very well, because they are written in a high-level language.  These instructions will, at some point, get to the machine much differently in machine language.  The machine language is a low-level language.  If you wish to read a story like version about this click here.

In general, you will go through several steps before you can get an output from your program;  1) First you will use an editor to type your program, 2) then you will use a compiler (in our case a C++ compiler) to compile your program and to get an executable file, and 3) at last, you will run the executable file to obtain the output.

The most important part of a programmer's job is solving the problem first.  It is much harder to solve a problem than to translate your ideas to a specific programming language.  Thus, one should first think about a method and develop an algorithm to solve the problem.  An algorithm is a sequence of precise instructions, which results in a solution.  The keyword here is precision.  If your algorithm has ambiguity in it, then you will not get the correct answer.

Exercise 1.1
Suppose you are helping the university registrar office with the registration process. You are to send students to six different halls depending on the first letter of their last names and the balance that has appeared on their bills.  Here are the criteria you will use to separate them:
Students with balance zero, Letters:
A-E in Hall 3, F-J in Hall 2, L-O in Hall 8, P-R in Hall 10, and S-Z in Hall 12.

Students with a non-zero balance go to Hall 18. These students can go back to register once they have a zero balance on their bills.

Write (or draw a diagram) to show the steps that your algorithm will take to solve this problem.  Here are a few hints: hint1, hint2, and hint3.