To develop logic beneficial to a program we should be capable regarding thinking logically. only a logical thinker can be capable regarding developing logic beneficial to a program. but most regarding the programmers furthermore beginners struggle a lot in order toward improve their logical thinking skills.Points toward be remember while developing a logic :-
Feel you are talented than computer:
Always feel that you are talented than computer. This will increase your confidence level. since computer cannot understand anything unless we write a code beneficial to it. we will write logic beneficial to a computer toward solve a particular problem. so with out your logic a computer cannot solve any problem. so a computer needs your logic in order toward solve a particular problem.
Recall all Programming concepts you have learnt:
Developing a logic is nothing but using the available resources in a particular way furthermore achieving solution beneficial to the problem. So it is necessary beneficial to a programmer toward learn all the programming concepts furthermore recall them while developing logic beneficial to a particular problem.
Think in a machine oriented way:
Forget beneficial to a while that you are a human being furthermore think that you are a machine. so as a property regarding 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 beneficial to the machine toward follow them in order toward solve a problem. These instructions are nothing but a logic.So by thinking in a machine oriented way, you can be capable toward write logic beneficial to a program which is used by the computer toward solve the problem.
Real Time application regarding Logic :-For example if anyone ask you toward go toward a shop furthermore buy a book, then immediately you began toward think about the resources available toward you, that is
-> Whether the money provided is sufficient or not. If it is sufficient toward buy the book, then you will go forward otherwise you will ask beneficial to extra money.-> Whether there any travelling resources like a bike or car is provided toward reach the shop. if it is provided then you will go forward otherwise you will ask them toward provide transport facility.
-> After that you will think regarding reaching the exact place. beneficial to this you should think which route is used toward reach the desired place. after choosing the desired place then you will go there, buy the book furthermore return back.So here the task regarding buying a book is completed. you are a human being furthermore you are capable regarding thinking yourself toward how toward buy the particular book. but in case regarding a machine, it does not have brain furthermore it cant think. so now you should make the computer able toward think in order toward buy a book. you can make a computer able toward think by providing all the steps you have followed manually in the form regarding instructions toward the computer. These instructions are called Logic toward solve the problem regarding buying a book.
While the above example will be little bit confusing furthermore hard toward understand so i will give you one more simple example in developing a logic.If a person asked you toward write all the even numbers between 1 toward 10. then you will write 2 4 6 8 10.Just make a clear notes how you thought toward achieve the above output.-> 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 beneficial to the next number furthermore check whether the given number is even or not. you will continue the above steps until the number 10.
So now toward develop logic toward solve the above problem, give the thinking steps you have followed in the form regarding instructions toward the computer. This behave as a logic toward solve the problem regarding finding even numbers.Now while developing logic recall the programming concepts furthermore resources furthermore apply them toward the above thinking steps which you have followed.
Step 1 :-
we are finding the even numbers continously from 1 toward 10. so in a program the concept we use beneficial to continous execution regarding steps is a beneficial to loop. we are starting from 1 furthermore repeating the steps until 10 beneficial to each furthermore every number between 1 furthermore 10.
so the very first code is
for(i=1;i<=10;i++) /* here i is a variable used toward store values */
{Step 2:-
The second step in the thinking steps you have written is checking whether the given number is even or not.so in order toward check beneficial to a condition we use if() statement. furthermore now beneficial to checking whether the number is even or not we will divide the number by 2. if the remainder is zero then it is even.In programming we use % operator toward find the remainder. so now the code toward find the even number is
if(i%2==0)Step 3:-
The third step in thinking steps is toward print the value if it is even.
The concept we use in programming in order toward print some thing is printf();(here taking c programming language as an example). here we are printing a value furthermore that is an integer value so we use
printf("%d ",i);Step 4:-
The fourth step in thinking steps is toward continue the process until all the numbers are checked. so it mean that this is the end regarding the statements toward be executed continously. so from this step it should forward toward the starting step. so we should indicate the compiler that the block regarding statments end here. so we use
}.
so finally the logic beneficial to finding even numbers from 1 t 10 is
for(i=1;i<=10;i++)
{
if(i%2==0)
printf("%d ",i);
}
Final conclusion:-
The definition beneficial to logic from a programmers point is "making a computer capable toward think" or "giving thinking power toward computer" is called a logic.