Wednesday, July 18, 2012

Do You Know How To Program?



Mobile iPhone Gaming Article 5

What is programming? If you never wrote a program you might be surprised that your train of thought is like writing a program.

Lets say that you have a recipe for making a salad. What are the ingredients for a salad. Well you need lettuce, tomatoes, onions, cucumbers, and salad dressing. Now you decide how much you need to make, lets say 4 people, Now how much ingredients, lets say 1 onion, 1 head of lettuce, 1 cucumber, and 1 tomato. Now to prepare the salad, you need to chop up the ingredients, throw them in a bowl, and add the dressing. So here are the steps so far:

Making a salad

How many people
Ingredients, how much
Prepare the salad
Serve the salad

Now break down the 4 steps

Step A: Quantity: We decided 4 people
Step B: Ingredients: 1 each onion, lettuce, cucumber, tomatoes, dressing
Step C: Processing: Chop all ingredients,toss with dressing, place in bowls
Step D Serve : Serve to family

Now what you have done in the above process is laid out the instructions for making a salad. What programmers call the above process is developing an algorithm. This is how you start the process of making a program.

The next area showing A-D is considered the main processes or routines that are needed to prepare the salad. Its a way to break a problem down to smaller steps. In programmer terms these are called routines.

The area showed as Steps A-D, are more detailed routines for each step. In the programming world these are called subroutines. These subroutines do the actual work for the routines.

Another thing you need to know about is variables. Variables are memory storage locations for data used in a program. You can have a variable for tomatoes which has the quantity amount of tomatoes. In this case tomatoes would be equal to one. Same for the other ingredients.

Another type of data needed is called a flag. A flag is used as a indicator to notify if something is done or not. A common type of flag be a yes or no, but in programming it is usually as simple as a yes or no or true or false.

Another area is a decision statement. In the above example you can say is the salad ready yet? If not do you have the ingredients, if so make the salad, if not go shopping.

One last area is for operator interaction. How many people are there for dinner? This calls for a response or input such as 4 people, or a (y)es, (n)o, (t)rue or (f)alse answer.

Oh and I forgot a way to show the information to the world can be a simple print statement like "Hello World!".

All these cover the basic small program. Next lesson I will start discussing Basic programming! See you then!

Barry

No comments:

Post a Comment