Do you think computer programming is a tough and tricky activity? Do you think it is the field for a few ‘nerdy’ ones? Then think again. [This article is mainly indented for C B S E students]
Computer programming is for everyone, people like you and me. Only thing is that you should know the techniques used by ‘real programmers’. You should acquire the mindset of these people. Then you should learn at least one computer language. It does not matter which language you choose, the programming techniques applied, are all the same. I will show you how to do this.
The mind set of a computer programmer.
When a programmer gets a programming assignment, the person thinks deeply about the actions and requirements needed to get the job done.
With out an example, all that I talk will be Greek and Latin to you, so let us take a simple example, a very basic one at that.
The assignment: Write a program to get two numbers and show the sum of these numbers.
Avery simple one, but do you know what actions you will have to do and what do you require to get this job done in real life?
The problem is very easy for you as a human being but it gets a bit complicated if we go in for the details.
Let us discuss the scenario.
So there you are, sitting at a counter offering to add two numbers and give the result to any person approaching you.
First of all, you need a sign board saying ‘Give me two numbers and I will give the sum of it’. Don’t you think that it is necessary? Well… how will other people know that you are sitting there to do such a great service, with you announcing it?
You need two places to jot down the numbers given by the person. You may think it is not necessary since you are good at arithmetic, but what if those numbers are really big ones? You will need one more place to write down the result of addition.
After getting the numbers and writing it down at the places reserved for this, you will have to do the calculation either in your mind or with the help of calculator. Then write it down it at the place reserved for answer. The last action is to show the result to the person.
So you see… if we look into the processes and requirements for a simple job as this we will be aware of the complexity of the situation.
Now let us take the problem to computer and ask it to do the actions, which we did, one by one that also in the same order.
Actions #1
Ask the computer to:
Reserve 2 memory positions to store the numbers to be calculated.
Reserve 1 more memory position to store the result.
Action #2
Ask the computer to: Display a message on the screen as “Enter two numbers to add”
Action # 3
Ask the computer to: Get the two numbers typed in by the person and store it at the two reserved positions
Action #3
Ask the computer to: Add the two numbers and store the result to the memory position reserved for it
Action #5
Ask the computer to: Display the result on the screen from the memory position
See what I mean? It is exactly as we did in real life. When we realized what the actions are and what we need to do the job in real life, we could easily convert it to a program.
So that is the mind set that I was talking about before.
I will come up with the next portion of the article in continuation… next week. We will eventually walk through your syllabus [CBSE] of C++ and may be even cover some database details.