By Sergey Skudaev
In this tutorial you will learn how to write a simple source code or computer program in C++. Besides, you will obtain some knowledge that is necessary for any programming language. There are many computer languages you can use to write computer program. If human languages are very different, computer languages are very similar. You, probably, will spend one-two years to learn the first computer language. The second one you will learn for couple of month or even less.
Computer programming is fun. Create a world from a word in Java or C++. A world that is logical, fair and predictable, that is everything what the real world is not.
To learn computer programming you need to understand few things:
1. What is variable, and what is data type?
2. How to understand function?
3. What is the difference between passing parameters by reference and by value?
4. How to understand pointer?
5. What is variable scope?
6. What is object oriented programming?
7. What is class?
8. What is inheritance?
9. What is polymorphism?
How to understand what computer program is? Have you ever read a screenplay? If you did, you know that first the author introduces a list of characters:
John Wilson - Web Developer
Joanne Wilson - his wife
Robert Gray - hacker
Then author shows characters in actions and we expect what each character will do. As screenplay develops we watch a sequence of scenes in which characters act.
A computer program has the same structure... First, programmer declares variables:
account_number integer
Balance double
Minimum_payment float
last name string
Expiration_date date
A variable name in any computer language must be one word. Often programmer use prefix to show variable data type. For example: strName for string data type or intAccount for integer data type.
Integer, double, string and date are data types. Each data type required different "space" in computer memory. For example integer occupy 4 bytes. Byte made of 8 bits. Bit is a smallest unit of information. It may contain zero or one. In binary system 00000001 equals 1. 00000010 equals 2, 11111111 equals 256 i.e. 2 in power of 8. 4 bytes can hold number from -2,147,483,648 to + 2,147,483,647. Double occupy 8 bytes and can hold huge number with decimals. Float occupies 4 bytes and can hold a number with decimals. When you prepare a gift box, you will not choose yard-by-yard box for diamond ring. It is not efficient way of packaging. The same thing with variables. You will declare data types according to you needs, so that computer memory will not be wasted. >> PART II - Pointers and Functions