Forgot your password?

Learn How to Program a Computer - Basic Starting Points

By Edited Nov 13, 2013 0 0

In order to program a computer, you must first understand a few basic computer fundamentals. You may have heard that computers are digital, that they work with numbers, that they can do amazing things. What does this mean? In order to program, you don't need to know the intricate details of the computer, but you do need to understand some basics. None of them are complicated so just about anyone from 5 to 80 years old can learn to be a computer programmer. In fact, it is a great idea to teach children how to program a computer.

Digital Computers
Computers are only capable of dealing with numbers. These numbers are whole without fractional parts. Programmers decide which of the numbers stand for which things. The number pi, (3.1415), for example, will be stored in the computer as "3" and "1415". Programmers can use pi, but the computer, being digital, will need to use pi as two separate components. Luckily the computer is extremely fast at this kind of math.

Binary System
All computing numbers are made up of binary digits only. Binary digits are either "1" or "0". Think of them as on or off. Large numbers require more binary digits. Here are the first binary numbers in sequence:

0000 - zero
0001 - one The right most binary digit is "on" to represent one
0010 - two Adding "1" causes the computer to turn on the next binary digit
0011 - three Adding "1" causes the right most digit to turn on again
0100 - four Adding "1" again turns on the next binary digit

Notice how there is only zero and 1 as digits. As the count goes up, the "1" digit keeps shifting to the left. More "1" digits are added on the right. Think of the digits as "bits". A bit can be on or off, 1 or 0. That is how the computer is designed. It simply turns an electric circuit on or off to signify the setting of each bit. By adding more bits, the computer can handle larger numbers. 1 bit can signify a number between 0 and 1. Two bits can signify 0, 1, 2 or 3. Three bits can signify 0 - 7.

While the early computer programmers needed to understand binary numbers completely, modern programmers are not required to. It does help, however, to understand the basics of the binary system. A good exercise for the beginning programmer is to carry the binary counting system further, up to "1111" to get a feel for the concept.

Central Processing Unit, (or CPU)
At the core of a computer, there is a central processing unit, CPU. All data must be brought to the CPU before anything can be done with it. The earliest computers had very a large CPU, usually one per computer and they were extremely expensive. Modern machines now implement the CPU as a very small computer chip and many computers have more than one CPU because costs have fallen so much. Beginning programmers should understand that their machine has a CPU that will execute instructions. If there is more than one CPU, the computer will usually run faster but we program it the same way.

Computer Memory
Each computer has memory. There are lots of different kinds in use today and many types have been made obsolete over the years. Just remember that there is something called computer memory. It will hold whatever digital information we put in it. Some memory is permanant, some isn't. For beginning programmers, it doesn't really matter what type is in use. Programmers use some of the memory to store data. An account balance is stored as a number in one area of memory. The computer instructions are stored as numbers in another area. Everything in the computer is stored in memory. In the beginning of computers, memory was very expensive, bulky and rare. Programmers did everything they could to minimize the amount of memory required to store data and computer programs. With modern gains in technology, memory is now a cheap computer component and is very plentiful. Most programmers now are free to use memory for whatever needed purpose without having to worry about cost or quantity available.

Programmers use parts of the computer memory to store numbers that will be changed. These are refered to as variables. They allow a programmer to track a quantity, (like a bank balance), in a memory location that has an easy to remember name. To the programmer, the bank balance is stored in a variable called "Balance". To the computer, "Balance" is a description of a memory location known as 1100, (or 12). Every time that the programmer wants to change "Balance", the computer must translate this into the number 12 then go to memory location 12 to get the balance.

Computer Logic
Programmers can use tests to have the computer perform different operations depending on certain conditions. For example, if an account balance is zero, then a customer might not be able to place an order. The condition check is usually done with a combination of english and math as in this example:

if Balance = 0
then print("There is not enough money for this order")

Computer logic can also be extended with additional checks:

if Balance = 0 and Customer_Credit > 1000
then print("There is enough money for this order")

Logic tests can use various words and symbols like "AND", "OR", "=", "<", ">", "<>". These logic operators will differ various computer languages, especially for the equal and not equal logic tests. Where it makes sense, programmers can put multiple checks into the same if statement. There is usually a limit to this type of complexity but the beginning programmer will not normally encounter it.

Program Control
Programmers can use other english words to control the computer's operation. "While" specifies that the computer should continue to do something until the test fails.

while balance > 0
balance = balance - 1

This trivial example specifies that a computer should subtract 1 from a balance repeatedly until the balance is no longer greater than zero. 5, 4, 3, 2, 1, 0. The computer stops when balance reaches zero. The computer will then find the next instruction to do. Depending on the computer language, there can be a "while" statement, "for", "until" and others.

Program Design
In order to get a computer to do useful things, it must be given a computer program. The design is like blueprints for a house. Before anything gets done, the design is created. The design is created and then the program is written. Most programmers use a simplistic programming style for design. This style doesn't exactly match any computer programming language but can be easily adapted into one. For example, the design for an order system might be started as follows:

Get the customer balance
If there is enough money, let the customer order a product
If not, let the customer know about the lack of funds

Each of these design steps can be translated into specific computer instructions. If there is a mistake in the design, or something needs to be added, the programmer can make necessary changes easily:

Get the customer balance
If there is enough money, or the customer has a good credit rating, let the customer order a product
If not, let the customer know about the lack of funds

Binary System Numbers from zero to 11

0000 Zero 0110 Six
0001 One 0111 Seven
0010 Two 1000 Eight
0011 Three 1001 Nine
0100 Four 1010 Ten
0101 Five 1011 Eleven

The above information should give you an introduction to the basics of computers and programming. The next step is to install the programming language of your choice. As discussed, Python is a great choice. It's free, easy and fast. It also runs on many computers and has a large, helpful user community. You next learning step should be how to install Python.



Add a new comment - No HTML
You must be logged in and verified to post a comment. Please log in or sign up to comment.

Explore InfoBarrel

Auto Business & Money Entertainment Environment Health History Home & Garden InfoBarrel University Lifestyle Sports Technology Travel & Places
© Copyright 2008 - 2016 by Hinzie Media Inc. Terms of Service Privacy Policy XML Sitemap

Follow IB Technology