# What is Programming?

1

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

3

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

4

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

Display area

Stop

7

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 per >=60 No per >=50 No per >=40 No Display “Fail” Yes Yes Yes

Display “Distinction” Display “First Class” Display “Second Class” Display “Pass Class”

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 computer’s 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 computer’s 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 Design
Gathering requirement and specifications

Coding into C

Implementation Testing

Keep program Working & Current

Algorithm and flowchart

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