Logic: The Basis of Computer Programming

来自女性百科
SawyersMcQueen3147讨论 | 贡献2013年7月24日 (三) 06:20的版本 (新页面: A computer program, as we've seen, is a group of directions that we issue to a computer for it to handle a task for us. To be able to tell the computer how to proceed, we must have the si...)

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航搜索

A computer program, as we've seen, is a group of directions that we issue to a computer for it to handle a task for us. To be able to tell the computer how to proceed, we must have the simple idea or steps involved with our brain that would be necessary to complete our task.This gives us to the notion of 'logic', which infact is the base and key of each computer program that you write - however simple or however advanced the program may be. The reason, basically may be viewed as the 'key' behind the answer of a problem. It's that step( education) or set of steps that form the main part of this program and will be the basis of the problem solving.Consider for example - choosing the average of 5 numbers input by a individual. What's the first thought that crosses your mind whenever you think of the answer with this problem? Simple math lets you know, we must increase the figures and separate them by 5. This very action, which forms the key to the solution of this problem is infact the 'reasoning' behind the solution of this task and what our program would be based upon.When we produce a program for the above task, we will Take the 5 numbers from the user Put them Partition them by 5 As we may clearly see, provide the result back once again to the userOut of these steps, the most applicable steps on the activity this system works and which depends our total production are 2 & 3 - adding the 5 quantities and dividing them by 5. If we were to improve these steps, the entire purpose and conduct of the program might change.Consider for a minute that we change steps 2 and 3 by the following: Take the 5 numbers from the person Just take the initial range & store it in a variable 'SMALLEST'

Get next number Compare with 'SMALLEST' If number Repeat step less than six for all outstanding 4 numbers

Supply the outcome saved in 'SMALLEST' back again to the userWhat can you discover here? The very first and last measures continue to be exactly the same http://www.facebook.com/jamesbumanglag/. What we have changed is the primary or the 'reasoning' of the program i.e. after the person has input the 5 numbers, we've changed what we do with the numbers! And this change today gives us the tiniest number from the 5 numbers feedback while the effect. This hence becomes a program to get the smallest number from a set of offered numbers!Having now seen the importance of logic to publish a program, we'd next be looking into the tools that help us write out the logic before we produce it into a ready computer program.