Thursday, 9 April 2009

Learn Programming Easily Step 3

I must apologize to the people following my site for not publishing an update for the past 2-3 days. I was a bit busy messing about with RSS and was sucked into the use of this format. Any way lets move on with what we were doing and that is learning the basics of programming.
As I showed you in my earlier post let me give you another example of a language neutral pseudocode

START
DISPLAY "2 + 2"
STOP

As you may have guessed this program will display 4 on the computer screen. WELL DONE..!

You are absolutely and utterly wrong. Why 2+2 is 4...? Yes you are correct in most circumstances yet this is the world of programming.
In this case I have used double quotes " this directs the computer to print whatever written inside the quotes as it is without using any intelligence or any logic. You get what you see no computation no meaning no logic nothing. Therefore the computer forgets about mathematics and prints whatever written inside the double quotes as it is. Again to re-emphasize my point. Let me ask you another question if I write

DISPLAY "Sandeep+4" what should it print. Forget about the meaning, don't think anything about the meaning(I accept the phrase is quite nonsensical) So if you were a ROBOT and just printing it as it is then it will print Sandeep+4 on the screen. For now please remember this do not forget it

DOUBLE QUOTE MEANS AS IT IS. IT DOES NOT HAVE ANY MEANING,NO MATHS,NO LOGIC,NO ANSWER, NOTHING. SHOWS ON THE SCREEN AS IT IS

With this wonderful weapon lets boldly go where no man has ever gone.... oops the Star Trek fan is getting a bit excited.
So what is this thing called. Is there a name for such things which are printed as it is and are written in double quotes?. There are plenty of names different people use to denote this kind of data. My favourite is 'Alpha-Numeric' constant. Again it is very important to understand the name. Lets take the word 'Constant' what does it mean? Again it means exactly what it sounds like.
A Constant is something which does not change irrespective of what you do with it. Best example in this category is your name. Lets say my name is Bruce does the meaning of Bruce changes every day or can you change the meaning of Bruce anytime you want. Can I say Bruce means Eddie or Bruce means 5. That is jibberish. You can noot change the value of a constant irrespective of what you do.

Now lets take the first part 'AlphaNumeric' it means the constant may have alphabets as well as numerics. Because we are not concerned with the value of a constant or what it means. To write your name on the screen you shall write DISPLAY "". To write your address DISPLAY "12 chester road london N2 3P". DISPLAY "MY SKYPE ID IS DER£$". This is sometimes also called String but lets keep thing simple for now. Anything enclosed in a double quote is a String/Alpha Numeric Constant

"23+43" prints------------------------->23+43
"Sudeep"prints----------------------->Sudeep
"*3+(78/34)+3" prints--------------->3+(78/34)+3
Until my next post keep repeating anything inside a double quote has no meaning for the computer. It will print it as it is. In my next post I will handle other data types or other constants.

No comments:

Post a Comment