Experienced

Monday, June 16, 2014

logical thinking

how to think logically ? This is the question in every beginners mind because Logical thinking is essential for every programmer. The students who are interested in programming should be capable to think logically. but basically most of the beginners suffer a lot to think logically and improve logical thinking skills. I already posted an article about logical thinking and its importance for a programmer in an introduction article. In case if you missed it then you can read it from this link. I hope my previous article had given you a basic view of logical thinking and motivated you towards the importance of thinking logically. In this post i will explain you about how to think logically while programming in order to develop logic for certain program. What is a logic in Programming ? logicIn programming, Logic is a small code snippet or the part of a program which consists of set of instructions to solve the given problem. A logic of the program consists of the actual statements which are to be executed by the computer in order to solve the problem. The logic for solvbing a problem is developed using set of instructions and embeeded them in a program by following the rules of writing a program. How to think logically in programming ? think logically Every programmer should think logically in order to develop logic for a program. but the problem arises here is how to think logically ? So in order to think logically we should learn how a logic will work and how to develop a logic for a program. I will Explain these concepts clearly below. Recommended for you : Introduction To Logical Thinking For a Programmer. How to develop a logic ? To develop logic for a program we should be capable of thinking logically. Most of the programmers and beginners struggle a lot in order to improve their logical thinking skills. Follow the below points to think logically and to develop logic for a program/code by own. Points to remember while thinking logically :- The below points are to be followed while thinking logically to develop logic for a program. Feel you are talented than computer: how to think logically in programming Always feel that you are talented than computer. This will increase your confidence level. Because computer cannot understand anything unless we write a code for it. we will write logic for a program to solve a particular problem using computer. So without our logic a computer cannot solve any problem. so a computer is in need of our logic to solve a particular problem. The computer works only on the basis of the code we write to it. This code is nothing but the logic for a program. so what you say ? we(the code developers) are talented ? or the computer ? so always think that you are talented than computer. Recall all Programming concepts you have learnt: programming languages Developing a logic is nothing but using the available resources in a particular way to find the solution for the problem. So it is necessary for a programmer to learn all the programming concepts and recall them while developing logic for a particular problem. Developing logic for the code becomes easy only if we have good command over all the programming concepts. Because concept is king in logic development. without knowing the concepts, you cannot develop logic for any code. So first learn the concepts in programming and recall all those concepts while developing the code. Think like a machine : computer thinking Forget for a while that you are a human being and imagine that you are a machine. so as a property of a machine that it cant understand anything. so feel that you cant understand anything. so if a machine cant understand anything, then we will give some instructions for the machine in the form of program to follow them in order to solve a problem. So by thinking in a machine oriented way, you can be capable to write logic for a program which is used by the computer to solve the problem. Machine oriented thinking is nothing but just forget everything and imagine that you cannot able to think. Imagine that you are just like a remote controlled car which operates upon the instructions given to it. So if you think that you are a remote controlled car then you will move forward if you receive an instruction to move forward. you turn left if you receive an instruction to turn left. So by thinking in this way you can have grasp over how a machine will work and how to give instructions to a computer or a machine. So that you can be capable to give instructions to the machine to work properly. Real Time Example of Logical Thinking :- I will explain about how to think logically and develop logic for a program using a real time example to buy books from a book store.  Example-Buying Books :- buying books For example if anyone ask you to go to a book store and buy a book, then immediately you will think about the resources available to you, that is Whether the money provided is sufficient to buy the book or not. If it is not sufficient, then you will ask for extra money. Whether there are any travelling allivances like a bike or car is provided to reach the book store. if it is not provided, then you will ask them to provide transport facility. After that you will think about how to reach the book store. To reach the book store you should think about the route way through which we can reach the book store. Then you will go to the book store, buy the book and return back. So here the task of buying a book is completed. you are a human being, so you are capable of thinking yourself to how to buy the particular book. But in case of a machine, it does not have brain and it can't think. In that case you should make the computer able to think in order to go to book store and buy a book. You can make a computer able to think by providing all the steps you have followed manually to buy the book in the form of instructions to the computer. These instructions are called Logic to solve the problem of buying a book. While the above example will be little bit confusing and hard to understand so i will give you one more simple example in thinking logically to develop logic for a program. Manual Process To Solve a Problem :- even number series If you are given a job to write all the even numbers between 1 to 10. then you will write 2 4 6 8 10. Just make a view on how you thought to achieve the above series. you just followed the below steps manually to find the even numbers from 1 to 10 Starting from number 1 Checking whether it is even or not. a number which is exactly divisible by 2 is called a even number. it means the remainder should be zero. If the remainder is zero(if it is even) then you will write the number. Then you will go for the next number and repeat step 2 then you will follow step 3 until the last number i,e 10 Developing Logic For Even Numbers Problem :- develop logic Now let us concentrate to develop logic for the above problem to solve it by a computer. To do so you should give the steps you have followed for solving the problem manually in the form of instructions to the computer. This behave as a logic to solve the problem of finding even numbers. Now while developing logic recall the programming concepts and resources and apply them to the above steps which you have followed. Step 1 :- we are finding the even numbers continously from 1 to 10. so in a program the statement we use for continous execution of steps is a for loop. we are starting from 1 and repeating the steps until 10 by incrementing the number at every iteration. so the very first code is for(i=1;i<=10;i++) /* here i is a variable used to store values */ { Step 2:- The second step you have followed to find even numbers is checking whether the given number is even or not by checking whether the number is exactly divisible by 2 or not.so in order to check for a condition, we use the conditional statement if(). and now to check whether the number is even or not we should divide the number by 2. if the remainder is zero then it is even. In programming we use % operator to find the remainder. so now the code to find the even number is if(i%2==0) /* Executes the next statement if the condition i%2==0 is true */ Step 3:- The third step you have followed to find the even numbers is to print the value if it is even.In programming, The statement used to print a message is printf();(here taking c programming language as an example). here we are printing a value and that is an integer value so we use printf("%d ",i); Step 4:- The fourth step you have followed to find the even numbers is to repeat the process until all the numbers are checked whether they exactly divisible by two or not. so it means that this is the end of the statements to be executed repeatedly. so from this step it should forward to the first step. so we should indicate the compiler that the block of statements end here. so to indicate the end of block we use }. /* used to indicate the ending of a block */ Final Logic :- So finally the logic for finding even numbers from 1 t 10 is for(i=1;i<=10;i++) { if(i%2==0) printf("%d ",i); } Final Conclusion:- man computer thinking The definition for logic from a programmers point is "making a computer capable to think" or "giving thinking power to computer" is called a logic. hope you have satisfied with this article. I will post more articles on logical thinking tips. So subscribe for our mail updates in order to get updated when ever a new article is published. please share your views in the comments section below.


Don't Miss Latest Job Updates

Get Job Alerts via Email

0 comments :

Post a Comment

Latest Post

 

Contact Form

Name

Email *

Message *

Popular Posts

Copyright 2013 Jobsplane Media . All rights reserved.
Protected by Copyscape Online Infringement Detector