Вы находитесь на странице: 1из 99

PROGRAM

A set of instructions given to a computer which the computer will do or follow Also called as Software

Note:
Software is not just the programs but also all associated documentation and configuration data which is needed to make these programs operate correctly.

Programming
The act of preparing or writing a program using a particular language called a programming language.

Programmer
Someone who does the programming or the act of creating a program. It could be you or someone who already knows how to program a computer.

Types of Software

System Software
The kind of software that controls and takes care of the working computer and overall functioning of the system. The best example of system software is the operating system Ex. Windows XP, Windows ME, Windows XP, Linux, Unix, Apples OS

Application Software
Software that generally suited to perform a particular task or function Ex. Word Processor, Spreadsheet, Computer Games, Desktop Publishing Software and Graphics Program

Types of Production of Software

Commercial Software
These are created and marketed by big software companies Usually made by a team of experts and computer professionals and are sold for quite a big price Ex. Microsoft Windows OS, MS Office

Shareware
Because of the high cost of software, many individual programmers made shareware Shareware, however is not really shared but is lent or allowed to be tested for a time before a fee is requested

Freeware
Given for free or allowed to be downloaded from the Internet. Programmers who create freeware do it as a service to users who cannot afford programs

Designing a Program

1. Determine Your Objectives


Reason why you need to create the program Define what the problem is

2. Devise a Method to Achieve your Objective


Break the problem into logical steps to achieve the solution You can use the flowcharts Type of approach

3. Write your Solution or Method as a Computer Program


Use a particular language to code your program

4. Run and Test the Program


Debugging the process of checking and correcting the errors Bug (Error in the computer termed by Grace Murray Hopper)

Lady Augusta Ada


First programmer Countess of Lovelace, Daughter of Lord Byron, Credited with innovating the loop, or repetition in Analytical Engine

Types of Test
Unit Tests each program is tested individually Integration Tests checks units have been combined correctly System Tests to see whether the overall system functions correctly

Types of Errors
Syntax Errors caused by incorrect punctuation, misspelled reserved words and so on. Run-Time Errors division by zero and integer overflow that occurs during execution. Logical Errors difficult to detect coz the program executes but does not produce correct results.

Programming Language
A notation for expressing instructions to be carried out by a computer. A medium of communication between the human and the machine and often, between one human being and another.

Reasons for Studying


Increased capacity to express ideas
Learning new data structures, algorithms, and other language features will allow a programmer to create more efficient programs
Example: after learning object-oriented programming in Java, a C programmer could simulate objects using structures and functions

Reasons for Studying


Improved background for choosing appropriate languages
Without having studied several different languages, programmers will tend to stick with the first language they learned
Example: A C programmer might implement a binary tree with arrays, instead of using the object-oriented capabilities of Java

Reasons for Studying


Increased ability to learn new language
Knowing the basic concepts of programming languages allows one to learn a new language easier
Example: C++ or Ada programmers, who already understand the concept of object-oriented programming, will have an easier time of learning Java then programmers have never used these concepts

Reasons for Studying


Better understanding of the significance of implementation
Knowledge of the basic concepts of programming languages enables the programmer to make more efficient choices with implementation and to find bugs easier in a program
Example: A C programmer who understands pointers can create the binary tree using structures and pointers, instead of with arrays, and will have an easier time debugging programs that use pointers

Reasons for Studying


Overall advancement of computing
Knowing the advantages & disadvantages of different languages helps those in charge to choose better languages over poorer ones
Example: In the early 1960s, Fortran was used much more than ALGOL 60, even though ALGOL 60 had much better control statements than Fortran

Classification of Programming Language

Machine Language
Language of every computer The lowest level since it is machinespecific and is not designed for a specific structure of a problem Equivalent to the instructions for operating the home appliances but computers are usually written in codes of a sequences of 1s and 0s

Assembly Languages
Structurally similar to machine language except that the sequences of 0s and 1s are replaced by mnemonic names for the operator part of the instruction and numeric and alphabetic symbols are used for the operands but still low-level

High-Level Languages
Higher than machine and assembly Have program structure divorced from the structure of the machine that execute them Designed to facilitate the writing of solutions to problems they are designed to solve Ex. Pascal, COBOL, BASIC, Fortran

Declarative Language
The most English-like programming language in its most expressive power and functionality The highest level of language to its counterparts and focuses more on Object-Oriented Programming Ex. VB, Java, C++, Smalltalk

Most Used Programming Languages

Assembler Languages
Uses: detailed control of hardware, used for internal computer control and operations Description: fast, efficient but require considerate effort and skill; has small program size

BASIC
Beginners All-purpose Symbolic Code Used mainly in education, business and at home Description: Easy to learn, but being nonstructured led to spaghetti style code, but later versions have updated to structured style

C
Uses: for systems and general programming Description: fast, efficient, and widely used, and popular among professional programmers

C++
Uses: for systems and general programming; commercial software development Description: developed from C, adding the advantages of objectoriented programming and more features such as streams

COBOL
COmmon Business Oriented Language Used for business programming Description: Oriented towards business and commercial applications not so easy to learn as it is quite wordy; widely used on mainframes

FORTRAN
FORmula TRANslation Used for scientific, mathematical and computational work Based on mathematical formulas; popular among engineers, scientists and mathematicians

Java
Developed for consumer electronics; used mainly for many interactive Web sites Multipurpose object-oriented language similar to C++ but is simpler; may also be used in other platforms

LISP
LISt Processing Used for artificial intelligence Symbolic language that is difficult to learn; widely used in universities and scientific research

PASCAL
General-purpose language Highly structured; easy to learn and widely used for teaching in programming in universities

PERL
Practical Extraction and Report Language Used for systems programming and web development Text and files are easily handled

PROLOG
PROgramming in LOGic Used in artificial intelligence Symbolic logic programming system It was intended for theorem solving but it is now used in artificial intelligence

Generations of PLs

First Generation
In 1940s and early 1950s, all coding was done in machine language Every machine has its own built-in code and this first generation of software every task was coded from scratch. It includes all low-level languages like machine and assembly

Note:
The word wasnt programming then, but coding and programmers were coders The word programmer originated in England, and when it finally crossed Atlantic in early 1950s it became more popular than coder

ACM
Association for Computing Machinery First formed for coding community in1947

Grace Murray Hopper


First coined the term bugs computing errors and debugging removing the errors While investigating Mark II computer was not working, discovered small moth in the machine and removed it with a tweezer

Mark III
Developed by Howard Aiken First to have a coding machine

Second Generation
The development and distribution of machine-code subroutines, interpretive routines, automatic code generators and assemblers Ex. ALGOL-60, BASIC, COBOL and FORTRAN

BINAC
Binary Automatic Computer Developed by Mauchly and Eckert Short-Order Code a set of interpretive subroutines stored in memory developed by Mauchly for BINAC

Third Generation
High level language that came out and perfected in the late 1960s up to present Ex. Procedural, functional logic and object oriented languages such as Pascal, ADA, Lisp, Prolog, C++, Smalltalk and etc.

Fourth Generation
Domain specific languages Ex. Visual Basic, Delphi, Visual Age, C++ Also languages for database systems like SQL, Access, FoxPro, dBase and etc..

Evaluation Criteria of PLs

General Criteria
Readability is it easy to read and understand a program or portion of a program written in the language? Writability Is it easy to write programs in the language?

General Criteria
Reliability does the program help prevent errors? Cost how expensive is it to develop, use and maintain programs written in the language

More Extensive Criteria


Simplicity Is there one (or few) way of expressing a concept? Orthogonality are there facilities highly independent. i.e., if there is a feature for sequence control, then no additional facility for sequence control should be present in the language?

More Extensive Criteria


Adequacy Is it possible to express the solutions to all problems to be solved in it? Syntax is the syntax clear and understandable? Redundancy Is there facility to guide programming by detecting and diagnosing inconsistencies of the programmer

More Extensive Criteria


Abstraction Is there a way to take virtually any internally consistent theme of a program, describe it, name it and use only the name subsequently? Assertions Does the language have a facility to state propositions that should hold regardless of the details of implementation (also called predicates, invariants, or properties)

More Extensive Criteria


Hierarchical Decomposition Is there a facility to express a top-down analysis of programming task? Modular Decomposition Is there a facility to express program units that may be semi-independently written or executed?

More Extensive Criteria


Sequencing Is there a facility to control the sequence of events during computation, fully or partially? Data Manipulation Is there a facility to carry out primitive operations on the data?

Flowchart
- pictorial representation of the logical steps it takes to solve a problem

Algorithm
It is a finite set of instructions that specify a sequence of operations to be carried out in order to solve a specific problem or class of problems

Pseudocode
-English-like representation of the same thing. -Pseudo is a prefix that means false -Code program is to put in a programming language -False code or sentences that appear to have been written in a computer programming language but dont necessarily follow all the syntax rules of that language

Types of Flowchart
Program Flowchart It describes graphically in detail the logical operations and steps within a program and the sequence in which steps are to be executed System Flowchart a graphic representation of the procedures involve in converting data on input media to data output form

Flowcharting Symbols and Usage

Input/Output Symbol (Parallelogram)

It is used to depict an input/output medium which is not specific. This is used in a logic flowchart.

Processing Symbol (Rectangle)

It represents a group of instructions that perform a processing function of a program

Decision Symbol (Diamond)

It denotes a point where more than one path can be taken. It is based upon conditions, a branch to alternative paths is possible .

Preparation Symbol (Hexagon)

It is used to represent an instruction or group of instructions that will alter or modify a program.

Terminal Symbol (Oval)

It is used to designate the beginning and the end of a program.

Pre-Defined Processing Symbol


(Rectangle with two vertical lines)

It is a specialized symbol representing a named operation not explicitly detailed

On-Page Connector (Small Circle)

It is non-processing symbol used to connect one part of flowchart to another without drawing flowlines.

Flowlines

Signifies the process that is to be executed next

Off-Page Connector (Small Pentagon)

It is used to designate entry to or exist from a page when a flowchart requires more than one page.

Punch Card Symbol (Rectangle with Notch)

It denotes for all types of card used.

Printed Document Symbol

It denotes any written information on paper. It could be a source of document from which data is collected or final output

Magnetic Tape (Circle with line)

It is used as an input/output symbol for magnetic tape files

On-Line Storage/ Magnetic Disk

It is used if the file is read/recorded on a magnetic disk

Variable
A character or group of characters that refers to a value and in the of a computer program, corresponds to an address

Rules in Naming a Variable


Variable names must be one word Variable names must have some meaning

Types of Variable
Numeric Value Character, text or String Variables

Notations Commonly Used in Flowcharting

Arithmetic Operations
+ * / Addition Subtraction Multiplication Division

Relational Operators
= > < <> >= <= Equal to Greater than Less than Not equal to Greater than or Equal to Less than or Equal to

Logical Operators
&& II ! AND OR NOT

Other Operators
EOF OAF CAF END START End of File Open All Files Close All Files End Start

Basic Control Structure


Sequence Selection or Decision (If-Then-Else) Repetition Looping) /Do-While

Sequence
Process is executed from one to another in a straightforward manner

Selection (If-then-else)
A choice is provided between two alternatives

Repetition/Do While
It provides for the repetitive execution of an operation or routine while the condition is true.

Reasons for Structure


Clarity as Program get bigger, they get more confusing. Professionalism all programmers expect your programs to be structured. Efficiency most newer computer languages are structured. Modularity it can easily broken into routines

Example of Sequence
Design a flowchart that will accept and display a number. Write its equivalent algorithms
Algorithm Step 1. Read in the value of N Step 2. Print the value of N

Example of Sequence
Draw a flowchart that will compute & display the sum of two numbers. Write its equivalent algorithm.
Initialize Sum into 0 Read in the value of A and B Compute the sum by adding A and B Print the computed value of Sum.

Advantages of Flowcharts

Advantages
Flowcharts are languageindependent, they can be learned and applied without formal knowledge of a programming language. It enforces users to give attention to significant matters over the less significant ones

Advantages
Being graphically portrayed, it provides an alternative to the usual narrative description of a system or a program Flowcharts are easier to understand than a program written in a particular programming language

Limitations of Flowcharting

Limitations
Flowcharts do not represent a programming language and are more of a person-to-person than a personto-computer means of communication. Since thinking in graphic terms is not normal, flowcharts cannot be viewed as a natural means of communication.

Limitations
Certain details often require a long sequence of interconnected symbols which could easily be described in just a few lines of explanation It does not convey why a given set operations is made Do not highlight the important details since each steps receives as much attention

Вам также может понравиться