Sunday, 26 March 2017

Let's learn Programming with C and Python - Part I

Hello, If you are reading this, I consider you as a beginner of programming.
Let's get to the point. Before going through Programming,

  A computer is nothing but a dumb tool just like others which will give output to your given inputs. when programming if you are getting errors it doesn't mean computer is doing some sort of errors, but you are program code is not delivering yours expected result.

Before starting with programming let us start with some aptitude, logic and reasoning.

Let us start understanding something with aptitude,

                             Whenever you are doing addition of two numbers, it is always "+", for eg,2+3=6
in the similar way, when you are finding the area of a Right angled triangle, it is always "base*height*0.5" and here it is always a decimal point number (Which is not at all an integer)

So, before thinking the outcome of your code is wrong check all your code before cursing your beautiful Machine.


Now it is our chance to know about Logic and Reasoning,

                             In Logic and Reasoning, when you are given an expression x + y = 10
and find x and y values, you can get infinite amount of results. which one you choose is your wish.
In a similar to solve a problem you can have so many methods. which one you follow is hardly up to you. (There is always a hard way and a shortcut way).

For example to swap two numbers from two variables a = 2, b = 3

It is always having two methods, one way is taking another variable "temp"
and doing like this,
temp = a
a = b
b = temp
Now the values are changed!!!

The other way is,
a = a + b
b = a - b
a = a - b
Now the values are changed!!!

The only difference is Logic that I used to swap two variables. (Even though the second one will save another variable that can be used some where else)

Finally, what I say is which logic you choose is your wish. But don't think about another logic while you are dealing with the first one. After completing with one logic then go with the other.


This is enough introduction. I will go with programming from my next blog post.

The next post will be on pseudo coding. till then stay tuned. Mean while try to do solve the known logic that you had on different problems in a different way which might be useful to you while writing your program.