Home
Intro
LC
ACR
About

Day 1 - Introduction to Programming

-=-=-=-=-=-=-=-=-=-=-

What you are going to learn today:

  • What programming is all about
  • The different parts of programming
  • And how all this relates to Pascal

-=-=-=-=-=-=-=-=-=-=-

Well, you're about to step into the wild, wacky, and completely out-of-control world of Pascal programming. But before you do so, you need to know the bare-bone basics of programming, and this is what this tutorial tries to do. This tutorial will introduce you to programming, what it is, how it works, and ways to make programming work for you, not you working for the program.

What programming is all about

Well, programming is about controlling the computer. That's why it's called programming. And how do you program? First, you use a language. Then you get a compiler, then Voila! You're a programmer! Pascal is an example of a programming language, and the only compilers on the market for Pascal come from Borland. Visit their website to find out how to get Turbo Pascal 7.0, if you don't have it yet. That's the compiler we'll be using throughout this webpage. Remember, programming can be both a fun and painful hobby, depending on how you view it. So, look on the bright side, and take it lightly. You're dealing with computers, remember? So just sit back and enjoy the ride!

The different parts of programming

Now, even before we even get into Pascal, let's ask the question you've all been waiting for: What is inside programming? Well, to answer this question, we'll try to tell you the typical parts of every programming language, whether it's Pascal, C++, or BASIC. Of course this list won't be complete, or accurate, but for the moment we'll be using this list to guide us on. Because this is pretty complex stuff, we recommend that you actually skip this entire list and go on to Day 2. Don't worry, everything will be explained in greater detail in the later tutorials.

Variables - storing values

(A) - name of variable, (1 + 1) - the result variable is to hold Well, let's start off with variables. (Devilish creatures, certainly) Remember those Algebra classes? Well, don't worry if you don't, because we're going to put you on a crash course right through!
All programming language work on something called variables, which work the same way algebra does. Each variable has a name and contains a value. For example, a variable can be named a, and contains the value 2. Thus you can say that a + a = 4 ! Easy, no?
Now, how do programming languages handle variables? Well, first, they put the variable they want to change in front, then the value it is to hold behind. Okay, so it seems weird, but its better than making a whole new concept for us to learn right?

Constants - staying the same

Essentially, constants are what they are, constant. A constant just simply replaces something else, like how some publications replace certain words with asterisks when nessecary. To give an example, let's say that we replace every appearance of the word "lamb" with "head" to make the sentence "Mary had a little lamb" to become "Mary had a little head". Thus, you could say that the word "head" was a constant representing "lamb", with apologies to all lamb-lovers out there of course.

Control Flow - changing directions

The if statement is a perfect example of control flow When you run through a list of instructions, you normally go through them step by step, but what if that's not the case? What if you are to press the red button when a tone is heard and the green one when not? What if you are supposed to scream when a meltdown occurs but shout when a fire starts? That's where control flow comes in to change the course of the program. Control flow is nessecary because you can't expect everything to be like a set of instructions. Changes have to be made.
For example, you can say, "Jump off the building if it is on fire, else continue typing your report." The statement above accomplishes something a list just can't do - change the direction.

Procedures - sub-routines

When you need to do something again and again, or to process some information, the programming mechanism you use is called a procedure. A procedure is something like a fixed set of instructions which can be repeated again and again. For example, a procedure may state, "Get the number of customers in the room and get the appropiate number of chairs". Thus, this procedure can be used in a concert, or a party, or any one of those lavish social occasions people never really care to go to. That's how a procedure works.

Functions - sub-routines which return values

A function is just like a procedure, except that it returns a value. For instance, we may have a procedure that accepts two numbers, one representing the number of Godzillas there are in a room, the other representing the number of innocent bystanders passing by, and calculates the average number of screams every 5 seconds. This is called a function because it returns a value, which is the average number of screams.

Comments - little notes

The final thing we have on our list are comments, which allow the programmer to add notes to his code. This makes the code easier for other people to read, and easier to change when debugging.

How this all fits into Pascal

Well, you'll see very soon that Pascal implements all these little aspects of programming in its own way, and in its own style too. For now, go get a can of Coke from the fridge. You earned it. Cheers! Now, go on to Day 2, where you really start programming!

-=-=-=-=-=-=-=-=-=-=-

HomeIntroLCACRAbout
Back to Class B

-=-=-=-=-=-=-=-=-=-=-

This page is ThinkQuest entry 11127.
email: tq97-11127@advanced.org