Variables. Data Types discussion.

Posted on at

Variables. Data Types.

The usefulness of the "Hello Worlds are easy" program shown in the previous section is quite questionable. We had to write several line of codes, compiles them, and then execute the resulting program just to obtain a simple sentence written on the screen as results. It certainly would have been much faster to type the output sentence by ourselve.

However, programming are not limited only to printing simple text on the screen. In order to go a little further on and to becomes able to writes program that perform useful tasks that really save us work we need to introduce the concept of variable. Let us think that I ask you to retains the number 5 in your mentals memory, and then I ask you to memorizes also the number 2 at the same times. You have just stored two different value in your memory. Now, if I ask you to add 1 to the first number I said, you should be retaining the number 6 (that is 5+1) and 2 in your memory. Value that we could now for example subtract and obtain 4 as result. The whole process that you have just done with your mental memories are similes of what a computer can do with two variables. The same process can be expressed in C++ with the following instructions set:

a = 22222222222;

b = 222;

a = a + 1;

results = a - b;

About the author