LATEST UPDATES

Search This Blog

Chapter 5: Principles of programming

Sunday, October 6, 2013

Chapter 5: Principles of programming

5. Principles of Programming
Program, Programming, Programmer, Programming Language
¡  A computer program is a sequence of instructions to solve a particular task.
¡  Developing a program is called programming.
¡  A person who writes a program is called programmer.
¡  The language, rules, syntax etc used to write a program is called programming language
Phases in Programming
To solve a problem by using computers the following steps are used.
1)   Problem Identification/analysis.
2)   Develop algorithm and flow chart.
3)   Program coding.
4)   Translation.
5)   Debugging.
6)   Execution and testing.
7)   Documentation.
1. Problem Identification/analysis
Here the programmer understands and identify about details of input, processing and output.
2. Develop Algorithm and Flowchart
a)   Algorithm
¡  Algorithm is a detailed step by step method / procedure to solve a particular problem is called algorithm.
¡  This name adopted from the famous Arabic mathematician Abu Jafar Mohammed Ibn Musa Al- Khwarizmi.
¡  It begins with input, the processing rules are in simplified form, and it may produce more than one output.
¡  It may be uses the words like start, stop, input, print etc. and step umbers.
Example 1. Algorithm to find simple interest for a deposit
1.    Start
2.    Input p,n,r
3.    I = p*n*r
4.    Print I
5.    Stop
Example 2. Algorithm to find the biggest from 3 numbers
1.    Start
2.    Input a,b,c
3.    If a>b then big=a
4.    else big=b
5.    If c>big then big=c
6.    Print big
7.    Stop
Example 3. Algorithm to find sum of first N numbers
1.    Start
2.    Input n
3.    i=1, sum=0
4.    If i<=n then goto step5 else goto step8
5.    Sum=sum+i
6.    i=i+1
7.    Goto step4
8.    Print sum
9.    Stop
b)   Flowchart
Flow chart is a pictorial representation of algorithm and it uses boxes of different shapes to denote different types of instruction in the algorithm. Flowchart provides better communication, effective analysis, easy to coding.
Symbols used in a Flowchart
Example 1. Flow chart for simple interest
Example 2. Flowchart to find the biggest from 3 numbers.
Example 3. Flowchart to find sum of first N numbers
3. Program coding
There are so many languages to communicate with the computer they are called programming language or high level language. E.g. BASIC, PASCAL, FORTRAN, COBOL, C, C++, VB, JAVA, ORACLE etc. It includes syntax and semantics to write program.
4. Translation
A program written in HLL is called source code. Language processors or translators are used to translate the source code in to object code. They are assemblers, compilers and interpreter.
5. Debugging
Finding and correcting errors in a program is called debugging. They are classified in to two
1) Syntax errors – It occur by violating the rules of programming language.
Eg: cin<<a; is wrong because the operator id violated here. The correct code is cin>>.
2)  Logical errors – They occur by a wrong or incorrect program step.
Eg: c=a+b is used for addition not for subtraction
6. Execution and Testing
It means running the program to give desired input and get the corresponding output. Here we check or test the program any types of inputs. In this time some errors may be occurring. They are called runtime errors due to division by zero.
7. Documentation
It is the process of providing sufficient information in a program to understanding its working to other programmers. It is also called comments enclosed in special symbols. (// or /* and */)

No comments:

Post a Comment

 

Welcome Plus one ,How you rate IT Club SKHSS

Members

Contact Form

Name

Email *

Message *

Visitors Counter

Most Reading

SREEKRISHNA HIGHER SECONDARY SCHOOL- IT CLUB. Powered by Blogger.