what is Program ?
A program is a collection of instructions that performs a specific task when executed by a computer.An algorithm and flowchart are the basic components of programming.
Programs can be written either in one of high level language which executes slowly, or low level language (machine or assembly language) which executes very faster.
main()
{
printf(“hello world!!n”);
}
Python Compiler
It converts instructions into machine language. We write a code is in the format of human readable or in a plane English text of course by following some specific set of rules associated with that programming language. Computer need something to translate those text into machine readable format.
Compiler translate your program that is source code (high level programming language) into machine code (or assembly language or low level language) to create an executable program.
Source code ——–à>>Compiler
——–à>> machine code
Keywords
A keyword is a reserved identifier used by the language to describe a special feature. It is used to declare an object, or in a function body to describe the statement executed. It can not be used as a constant or variable or any other identifier name.
For instance, if you use any reserved keywords in python like pass or class then check here what complications could introduce in your simple program.
Algorithm
An algorithm is a step by step guide written to solve the problem in a very simple way or in a plane English language. It is a roadmap of your thoughts – where to start, what to start, how should proceed and wrapping up your program. It represents process or flow of your program in a simple words.
The main motto of designing of an algorithm to have clear understanding on requirement and its solution. Anyone from outside who doesn’t familiar with programming language can understand overall picture of your so complicated program logic in a very generic way. An algorithm is used to create the flow chart.
Examples
Let’s take an example: Write an algorithm to add two numbers!
1. Start
2. Take two numbers (x and y)
3. Apply formula to perform your task: (ans=x+y)
In this example; we can add two numbers (x and y) and store result in variable “ans”.
4. Display result
5. End
Here is one more – Write an algorithm to check whether seller has profit or loss.
1. Start
2. Collect the product data from seller- Its selling price and actual cost.
3. Apply formula to calculate profit
(Profit = selling price – product cost)
4. Take a decision –
– if profit is greater than zero; that means seller got some profit in business
– if profit is less than zero; that means seller got some loss in business
– if profit is equal to zero; that means seller neither got profit nor loss.
5. Display result
6. End
Everyone has our own views to look at the problem and of course has the different ways to solve it. Here is one of the alternatives to check profit or loss.
3. Apply formula to calculate profit
(Profit = selling price – product cost)
4. Take a decision –
– if selling price is greater than product cost; that means seller got some profit in business
– if selling price is less than product cost; that means seller got some loss in business
– if selling price is equal to product cost; that means seller neither got profit nor loss
Likewise, you can write algorithm of your program in a very simple way.
Try this one on your own in comment section below – Write an algorithm to calculate average of five numbers? Or maybe this one – To check whether entered numbers are even or odd?
Flow Chart
The flow chart is a graphical or symbolic representation of your algorithm, process or workflow.
This diagram representation demonstrates a solution model of a given program. Flow charts are being effectively used in analyzing, designing and managing processes in the big projects. It is essential part of the program especially when you are dealing with the complex requirement.
Flow chart has its common alternative names include: flowchart, process flowchart, functional flowchart, process map, process chart, functional process chart, business process model, process model, process flow diagram, workflow diagram, etc.
Symbolic representation
Overview of common symbolic representation of flow chart:
Let’s try to build flow chart of our second example algorithm – to check whether seller has profit or loss.
What are your thoughts on “What is program, algorithm and flow chart” ?