Home Programming Logic: The Foundation laptop or computer Programming

Logic: The Foundation laptop or computer Programming

5 min read
Comments Off on Logic: The Foundation laptop or computer Programming
0
171

A pc program, as we view, is some instructions that people issue to some computer for this to do a job for us. So that you can tell the pc how to proceed, we have to possess the fundamental idea or steps involved with our mind that might be needed to accomplish our task.

This raises the idea of “logic”, which infact may be the base and core of each and every software program that you simply write – however simple or however complex this program may be. The logic, basically might be viewed as the “trick” behind the answer of the problem. It’s that step(instruction) or group of steps that make up the key to this program and it is the foundation from the problem-solving.

Consider for instance – locating the average of 5 figures input with a user. What’s the first believed that crosses the mind whenever you consider the answer of the problem? Simple mathematics informs you, we have to add some figures and divide them by 5. This very step, which forms the main towards the solution of the issue is infact the “logic” behind the answer of the task and just what our program would depend on.

Whenever we write a course for that above task, we’ll

Go ahead and take 5 figures in the user

Add them

Divide them by 5

Provide the result to the consumer

In the these steps, as possible clearly see, probably the most pertinent steps which depends our entire output and also the action this program performs are 2 & 3 – adding the five figures and dividing them by 5. When we would change these steps, the entire purpose and behavior from the program would change.

Consider as it were that people replace steps 2 and three through the following:

Go ahead and take 5 figures in the user

Go ahead and take first number & store it inside a variable “Tiniest”

Take next number

Match up against “Tiniest”

If number < “SMALLEST” Then, store this number to “SMALLEST”
Repeat step 3 to 5 for all remaining 4 numbers
Give the result stored in “SMALLEST” back to the user
What do you notice here? The first and last steps are still the same. What we have changed is the core or the “logic” of the program i.e. once the user has input the 5 numbers, we have changed what we do with the numbers! And this change now gives us the smallest number from the 5 numbers input as the result. This thus becomes a program to find the smallest number from a list of given numbers!

Having now seen the importance of logic to write a program, we would next be looking into the tools that help us draft out the logic before we formulate it into a ready computer program.

Load More Related Articles
Load More By Thomas George
Load More In Programming
Comments are closed.

Check Also

AGM Live polling – All you need to know

Six Media has a unique landing page for AGM live Polling which is known to come with some …