Programming Concepts
Programming Basics
A computer program is a set of code
written in a computer language. It is executed on a computer to perform
particular tasks on the computer. Programmers developed the code using a
programming language. In other words, Programming is the process of creating a
set of instructions to perform a task on the computer. Programming is the
process of giving machines a set of instructions that describe how a program
should be carried out.
Programming can be done using a
variety of computer programming languages, such as JavaScript, Python, C, Java
and C ++.
Examples of compiled programming
languages would be C and C++.
Program
Development
Algorithm:
It is a set of instructions for solving a problem step by step. It is a list of steps to complete a task or
solve a given problem. Example – Algorithm to find
the area of the Rectangle.
- Start
- Take
length and breadth as input
- Calculate
area of rectangle –> area = length x breadth
- Display
area of the rectangle
- Stop
Program:
It is the implementation of
Algorithm in a computer language. It is executed by the computer to accept
length and breadth of the rectangle, computer then calculate the area and
display the area on the screen.
#include<iostream.h>
int main()
{
int length, breadth, area;
cout<<"\n Enter Length";
cin>>length;
cout<<"\n Enter Breadth";
cin>>breadth;
area = length * breadth;
cout<<"\n Area<
return 0;
}
When
above code is executed on computer.
It is the order or the sequence in
which the steps are to be followed or the instructions to be executed to solve
the given problem or accomplished a task. For example, in the above code, area
cannot be calculated without accepting the length and breadth of the rectangle.
Representation
of Program Logic:
A customer when requires to
construct house or an apartment, approaches architect. Architect acquires the
complete requirements from the customer. Then the architect creates the model
or the blue print. The customer verifies it as per the requirements; if not
model will be redesigned until the customer requirements are met.
Programmers use the same approach
in designing and developing the programs. Once the developer understands the
complete requirements, prepares the flowchart to represent the program logic or
defines the steps in English like language.
Pseudo
Code:
It
describes the algorithm in a English like language that can be easily used to
develop the code. It is used for
creating an outline or a rough draft of a program. Pseudo code summarizes a
program's flow, but does not include underlying details of the Algorithm.
Following is the Pseudo code to accept length and breadth of Rectangle and display its area.
1 Start
2 Accept Length and breadth
3. Calculate area
4. Display area
5. stop
Flowchart:
It is the pictorial or graphical
representation of the program logic. A picture worth a thousand words. A
flowchart is also defined as a diagrammatic representation of an algorithm, a step-by-step
approach to solve a task or solve a problem.
The flowchart to accept length and breadth of rectangle and display its area is shown below:
A computer program is based on an
algorithm (a sequence of activities). An algorithm is represented using pseudo
code (steps in English text statements) or a flowchart (pictorial or a
graphical representation to indicate the flow of action).
Pseudo code and flowcharts are used
to help programmers to understand the algorithm correctly to plan and develop
their proposed program.
Variable
A variable in programming world is
a name given to a memory location. A computer takes data to be processed as
input and stores in main memory i.e. RAM. The program instructions access data
from memory process it and store results of computation in main memory. The
question is how the program knows the location of data in memory. The memory
location is a given a name called a variable in programmers world.
Language used in
Flowchart and Pseudo class:
Print “hi friends!!!” |
Used to display a message on the screen or output device. |
Print area |
Used to display the contents of the variable area |
Print “Area = “, area |
Used to display both message and contents of the variable area. |
1)
Accept
or Read or Input
It used to accept or take input
from the user through the Input Device and store in main memory.
Example; Input length, It takes a
value from the keyboard and stores in the main memory location named length.
Processing Statement
It is used to indicate processing
i.e. performing arithmetic operations.
Example: - area = length * breadth,
means get the contents of the memory location named length and breadth,
multiply and store the result in memory location named area.
Flowchart Symbol

No comments: