Pages

Saturday 25 June 2011

Pseudo Codes



As stated earlier, an executor can execute an algorithm if he/she understands the language of the algorithm. In case it is desired to execute the algorithm by computer, the algorithm must be translated into a computer language, An algorithm written in computer language is known as a computer program. There exist a number of programming languages, each with their own advantages and limitations.

However, since it is not known, a-priori, which programming language will be used for coding the algorithm into a program, an intermediate language, which is somewhat between English and a true programming language, is used. This language is called Pseudo-code.

Pseudo-code defines the logic to be used in the program, and is referred to as being "neat notes to yourself". As notes the pseudo-code you write for a program is not the detail code for the program - if it were then it would not be notes! Therefore, when you are creating the pseudo-code, you are providing enough information to "jog your memory" as to what is needed, and work through the logic flow of the program. Keep in mind also that someone else could, in theory, use the pseudo-code you create for writing the program in FORTRAN, C++, Visual Basic, etc. Because of this reason, you don't want to use too many "language specific" references, but rather use "generic" programming constructs.

Pseudo-code is written in plain English. Higher-level languages, such as SQL represent the move towards plain English in programming languages and close the gap between pseudo-code and regular code. Often pseudo-code is a manner in which you can "line up" all the elements you think you will need in a program upfront. You can think through the problem on paper and perhaps merely replace C specific constructs in your pseudo-code. In this manner, pseudo-code can even foster portability between languages.

The pseudo-code shown below isn't completely "generic", but it shows how the concept of this programming tool should be used.

Example 1
Describe a pseudo-code to calculate the sum of the numbers from 1 to 100:
To solve this problem, you may realize that you can use the equation sum I n(a + b)/2 to solve this problem. You take, this knowledge and write down (in English terms - pseudo-code) the step-by-step process required to solve this problem.
The process may resemble the following pseudo-code:
set n equal to 100
set a = 1
set b equal to 100
calculate sum = n(a + b)/2
print the sum

c programmming online,basic of c language,structure of c programming,c language statements,Compiling a C Program,Pseudo Codes in c,basis data type in c ,variables in C Program,constants in C Program,c operators in C Program,special operators in C ,Decision Making,Branching & Looping in C Program,if statement in C Program,for loop in C Program

No comments:

Post a Comment