Computers have been around us for many years now. They are placed on our desks, inside our phones, and inside our cars and washing machines. Computers do their work by following instructions. These instructions are bundled together, as computer programs. The programs are then executed, which means that the instructions are followed, sometimes one by one and sometimes more than one at the same time, and the computer does what the instructions tells it to do.

The act of creating computer programs is referred to as programming, or if you wish to make it more clear, computer programming. This book has the goal of giving you an introduction to computer programming. It will do so by describing the basic elements of a programming language, and how these elements can be used to create programs.

Before learning how to do the actual programming, it is important to gain experience with the practical usage of computers. I will assume that you have such practical experience, and most likely you are using a computer, or perhaps another type of electronic reading device, right now, as you read this text.

If you read the book on the web, you are typically using a browser program, such as Firefox or Opera. If you use another reading device, such as a tablet computer, you may be using some kind of reader software, like a Kindle reader program or an iBooks program.

There are many types of computer programs, used in different scenarios, such as programs for word processing, program for making numerical calculations, programs for reading e-books, and programs for controlling the speed of your car or the temperature of your washing machine.

The programs described in this book will be small compared to a browser program, and they will also be small compared to a car control program, but they might still be useful for learning the important concepts.

Read more

Names and values

Programs need to keep track of information when performing their tasks. A program computing your salary needs to keep track of your salary, your tax, and most likely also some information about your bank account. For this purpose, programs often use variables, which can be assigned values.

Read more