1 What Is Programming PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

What is Programming?

Definitions

Program
A set of directions telling a computer exactly what
to do.
Programming languages
Languages for specifying sequences of directions
to a computer.
Algorithm
A sequence of language independent steps
which may be followed to solve a problem.
Flowchart
Diagrammatic representation of step for solving
the given problem.
2

Many Aspects of Programming


Programming is controlling: computer does exactly what
you tell it to.
Programming is teaching: computer can only learn to do
new things if you tell it how.
Programming is problem solving: always trying to make
computer do something useful i.e., finding an optimal
travel route.
Programming is creative: must find a good solution out of
many possibilities.
Programming is modelling: describe salient (relevant)
properties and behaviours of a system of components.
Programming is abstraction: identify important features
without getting lost in detail.
Programming is concrete: must provide detailed
instructions to complete task

Sample Algorithm
Calculating area of the circle.

Algorithm:
1.
2.
3.
4.
5.

Start.
Input radius in cm.
Calculate, area = 3.14 * (radius * radius)
Display area.
Stop

Sample Algorithm
Calculate the division obtained by the student according
to inputted marks.

1. Start.
2. Accept five different subjects marks,
i.e. m1, m2, m3, m4, m5.
3. Calculate, per = (m1+m2+m3+m4+m5) / 5
4. If per>= 75 then display Distinction else
If per>= 60 then display First class else
If per>= 50 then display Second class else
If per>= 40 then display Pass class else
Display Fail.
5. Stop.
5

FLOW CHART SYMBOLS


Start / Stop

General Processing

Decision

Input / Output

Connector

Function / Subroutine
6

Calculating area of the circle.


Start

Input radius
in cm.

Calculate area =
3.14 * (radius * radius)

Display
area

Stop

Start

Accept five different


subjects marks i.e.
m1, m2, m3, m4, m5.
Calculate, per =
(m1+m2+m3+m4+m5) / 5

Yes
per >=75
No

Yes

per >=60
No

Yes

per >=50
No
per >=40

Yes

Display
Distinction
Display
First Class
Display
Second
Class
Display
Pass Class

No
Display
Fail

Stop
8

Final Maze Solving Program


step forward;
while (inside the maze?)
{
turn right;
while (facing a wall?)
{
turn left;
}
step forward;
}
9

Programming Languages
Machine language:
It is computers native language having a sequence of zeroes
and ones (binary). Different computers understand different
sequences. Thus, hard for humans to understand: e.g. 0101001...
Assembly language:
It uses mnemonics for machine language. In this each instruction
is minimal but still hard for humans to understand:
e.g. ADD AH, BL
High-level languages:
FORTRAN, Pascal, BASIC, C, C++, Java, etc.
Each instruction composed of many low-level instructions,
closer to English. It is easier to read and understand:
e.g. hypot = sqrt(opp*opp + adj * adj);
10

Running Compiled Programs


We want to code the program in a high-level language, C
But each type of computer only understands its own
machine language (zeroes and ones)
Thus we must translate from C to machine language.
A team of experts programs a translator, called a
compiler which translates entirety of a C program to
an executable file in computers native machine
language with checking for syntactical errors.
Process:
compilation: Your program executable file
machine executes your program by running each
machine language instruction in the executable file.

11

Software Development: A 5-Step Process


Analysis

Coding into C

Design
Gathering requirement
and specifications

Implementation

Algorithm and
flowchart

Keep program
Working &
Current

Testing

Checking the
program execution and
debugging

Maintenance
Result: Working Program
12

Errors

Debugging is the process of detecting and fixing


errors found in a program.
Syntactic errors are caused by giving the compiler
a program it cannot recognize.
Logical errors come from programs that compile
correctly but fail to execute as expected.
Programs must be designed carefully and tested
thoroughly to ensure that neither error will occur.

13

Created By,

Mr. Tushar B Kute,


Lecturer in Information Technology,
K. K. Wagh Polytechnic, Nashik.
tbkute@gmail.com

14

You might also like