Showing posts with label Logic. Show all posts
Showing posts with label Logic. Show all posts
Posted by Sameer on 2:36 AM
Labels:

Wikipedia defines logic as the study of the principles of valid demonstration and inference. When we face a problem, we apply brain to get through it. i.e. We apply some logic considering the surroundings, the type of problem and the tools we have to solve it. The problem we face might be a real life difficulty, a mathematical problem, a scientific query etc.

Sometimes, Logic gets applied even when we are not conscious of it. On the other hand, sometimes we have to think really hard to solve a simple problem. Sometimes, In spite of knowing the solution, we fail to reach the same. Why do you think this happens?



Now, Consider the following problem.
Draw a circle when you are provided with a pencil and a scale.
Solution:


Draw a circle when you are provided with a pencil and a pro-circle.
Solution:




What do you observe? The logic applied in both the cases is different from one another. Also, The nature of your circle changes depending upon the instrument you use. By using a pro-circle, fine circle can be drawn. Circle drawn using a scale is not fine. A particular problem can be solved in many ways. The nature of solution differs for each approach. Now, if I reduce the length of each line used to draw the circle, the circle drawn using the scale can also be made fine. To find an optimum solution for a problem, sometimes you may have to apply extra efforts. For a brain, these efforts depend on the 'things' and 'tools' a man has and also the surroundings.

Now, let us come to my topic. Wikipedia defines Programming logic as the use of mathematical logic for computer programming. My experience is,'more than 60% of people find it to be very hard'. At first, I used to think in the same way. But when you know the reason of it to be difficult, it starts becoming easy. Let me explain my point. C++,Java,HTML, Visual Basic, Game editors are some of the programming languages, I'll be using for reference.

In computer science, Programs are written in specific languages which can be understood by the computer. C,C++,JAVA,Visual Basic are some of them. Now, my point is, one can not draw a circle if he/she doesn't know how to use a pro-circle. It does not mean that one doesn't know, how a circle looks like. The only problem is, he is unaware of the approach to complete the task.
The main reason of one being unable to write a program or to apply a logic, is not because he is an dumb-ass in computer programming. The cause behind this is, he is not familiar with the ways and tools to approach the problem. I don't disagree the fact that the lack of knowledge of a concept is responsible for one being not able to tackle a problem. But, I think all of us know 'how to add two numbers'.

Consider an simple example.

A variable 'a' has a value '10' and 'b' has a value '15'.

Consider following code snippet.(Code is in C++)

if(a>8 & b=15)

cout<<"true";
else
cout<<"false"; ('cout' in C++ is used to print a message.)

The output of the above program should be 'true'. However, the computer gives an 'error' and can not execute the code. The correct code is:

if(a>8 & b==15)

cout<<"true";
else
cout<<"false";

Now the output is 'true'.The logic I applied was perfectly all right.You also must have applied the same logic. The only thing I didn't know was the symbol for 'equal to' in C++ is '==' but not '='. Is it not cool? One thinks that the logic he has applied is wrong.

Once you get familiar with different tools, accessories, options, commands and techniques of a programming language, the only thing that remains is to apply logic which suits the above environment. You need to apply different logic in different languages for solving the same problem.

'Logic' and 'Language' are two different things.But they follow the same universal law.The 'Logic' can not be expressed without a 'language'.The 'Language' is senseless without the 'Logic'. Language and Logic do influence each other. Apply the logic, know the language and your problem gets solved. That's the way of programming.



You should ,Someday, peep into the world of programming. It's easy. It's simple. It's beautiful. You would love it. I'm sure.
-----------------------------------------------------------------------------------------------


This post is dedicated to my wonderful brother 'Siddhesh' who was the first to teach me the true meaning of 'PROGRAMMING'.