How to represent the algorithm in programming?
The algorithm is the finite sequence of steps that are designed to solve the given problem. It defines or tells how your program code works or runs irrespective of the programming languages you use in order to solve the problem. In fact, you don't have to know any programming languages in order to write the algorithm of your program code.Basically, there are three ways to represent the algorithm of your program code. They are the flow chart diagram, pseudo code and the natural language itself. Let me discuss one by one in details
as follows. For the explanation purpose, I will do with the even and odd number problem algorithm.
Natural Language.
In this method, we describe the algorithm in natural language as simple as that. Anyone can understand it. It is very simple and easy to write. For example,1. Start
2. Get the number from the user and store in variable N
3. Now divide the given number N by 2 and check the status
If the number N is divisible by 2 then the status is even number
Else the number status is an odd number
4. Display the status
5.End
Pseudo Code.
It is similar to the actual program code that you write. But it does not require any programming language syntax to write it. It may vary person to person the way you write pseudo code as it does not have any standard syntax or rule to write it. For example,Algorithm evenOdd(n):
if n%2 == 0:
display "Even"
else:
display "Odd"
Flow Chart Diagram.
It is the diagrammatic representation of the algorithm by using various shapes and arrows to connect it together. It has some standard shape diagram to represent the flow chart. You can click on the Standard Flow Chart Symbol to see all of it. For example,Even and Odd FlowChart |