Sunteți pe pagina 1din 24

Computer Program

Computer Program
Set of instructions To design a program we need Instructions Order Data
Ex:
A, B C=A+B C

Program Development Cycle


Analyze/Define the problem Task analysis Developing algorithm Testing the algorithm for accuracy Coding Test and debug the program Documentation Implementation Maintenance and enhancement

Algorithm
Finite sequence of explicit instructions, when provided with a set of inputs, produces an output and then terminates Finite number of steps Ex: Find the area of a rectangle. Step 1: Start Step 2: Input the length (l) and breadth (b) of the rectangle. Step 3: Find the area of the rectangle using the formula. Area l*b Step 4: Print the area of the rectangle. Step 5: Stop.

Algorithm
Characteristics of Algorithm Precise and unambiguous No infinite repetition Ensure termination Finite number of steps in sequence Normal English Qualities of good algorithm Time Memory Accuracy Sequence Generability

Flowchart
Pictorial representation of an algorithm in which the steps are drawn in the form of different shapes of boxes and the logical flow is indicated by interconnecting arrows Boxes operations Arrows sequence

Flowchart symbols
flow lines Terminal Input/Output Processing

Decision

Connector

Off-page Connector

Document

Annotation

Manual input

Manual operation

Online storage

Disk

Summing Junction

Sequential Access Storage

Direct Access Storage

Flowchart
Benefits of flowchart Makes logic clear Communication Effective analysis Useful in coding Proper testing and debugging Appropriate documentation Limitations of flowchart Complex Costly Difficult to modify No update

Pseudocode
PDL (Program Design Language) Uses plain English statements to represent the processes of computer program. Input: READ, OBTAIN, GET, PROMPT Output: PRINT, DISPLAY, SHOW Compute: COMPUTE, CALCULATE, DETERMINE Initialise: SET, INITIALISE Add one: INCREMENT

Pseudocode
Benefits of Pseudocode language independent easier to develop easy to translate compact Limitations of Pseudocode does not provide visual representation no accepted standards no syntax rules

Program Control Structures


Sequence control structure
Flowchart example Start Action 1 X=10,Y=20 Action 2 Z=X+Y

Print Z Action N

Stop

Selection Control Structure


Start No If condition True? Yes READ A,B

No Action 2 Action 1

If A > B

Output B

Output A

Stop

Repetition Control Structure


Start Repeated task

Count=0

Count=Count+1 Condition false Print Count

Yes true

If count<10 No Stop

PROGRAMMING PARADIGMS
Programming paradigm refers to how a program is written in order to solve a problem. Programming can be classified into three categories: Unstructured Programming Structural Programming Object-Oriented Programming

Unstructured Programming
Unstructured style of programming refers to writing small and simple programs consisting of only one main program. All the actions such as inputs, outputs, and processing are done within one program only.

Structural Programming
Using structural programming, a program is broken down into small independent tasks that are small enough to be understood easily, without having to understand the whole program at once. Each task has its own functionality and performs a specific part of the actual processing. These tasks are developed independently, and each task can carry out the specified task on its own, without the help of any other task. When these tasks are completed, they are combined together to solve the problem

Object-Oriented Programming
Object-oriented programming is a style of computer programming, which promotes building of independent pieces of code that interact with each other. It allows pieces of programming code to be reused and interchanged between programs.

Programming Languages
Has to follow syntax rules to create an accurate program so that the computer can yield desired results. Rules are very rigid Types of programming languages Machine language Assembly language High level language

Generations of Programming Languages


First Generation: Machine language 2 states ON and OFF (1 and 0) Advantages Translation free High speed Disadvantages Machine dependent Complex language Error prone Tedious

Generations of Programming Languages


Second Generation: Assembly language Interact directly with hardware Mnemonic instruction General format
Label Begin Opcode Operands Comments ADD A, B ; Add B to A

Assembler Source code (assembly language) to object code Variables are symbolic names Translates mnemonic codes to m/c code and register addresses to system addresses Checks syntax, assembles into main memory and provides linking facility

Generations of Programming Languages


Advantages Easy to understand and use Less error prone Efficiency More control on hardware Disadvantages Machine dependent Harder to learn Slow development time Less efficient No standardization No support for modern software engineering technology

Generations of Programming Languages


Third Generation: High-level language Can be machine independent Compiler Interpreter Linker Loader Allocation Linking Relocation Loading Two types: Absolute loader and Relocating loader

Generations of Programming Languages


Advantages Readability Machine independent Easy debugging Easier to maintain Low development cost Easy documentation Disadvantages Poor control on hardware Less efficient

Generations of Programming Languages


Fourth Generation: 4GL Query languages Report Generators Application Generators Advantages Shorter time for development and debugging Non-procedural Use of procedural templates and data dictionaries Disadvantages Very lengthy Cannot utilize the power at h/w level Fifth Generation: Very high level languages AI and expert systems

S-ar putea să vă placă și