PLF Chapter1

27
Introduction to Program Logic Formulation With Basic C Chapter 1

Transcript of PLF Chapter1

Page 1: PLF Chapter1

Introduction to Program Logic

FormulationWith Basic C

Chapter 1

Page 2: PLF Chapter1

Data are raw facts and figures which are meaningless.

Information are useful processed data.

Data and Information

Page 3: PLF Chapter1

Procedure is a logical sequence of actions, either consciously or subconsciously, to carry out a certain task or process.

Elements of Procedure

◦ Action – the sequence of steps to be taken◦ Order – specifies the logical arrangement of the

actions◦ Data – the elements operated upon by the action◦ Language – the medium of communication

Procedure vs. Computer Program

Page 4: PLF Chapter1

Computer is an electronic device designed to manipulate data.

Program is a set of instructions to carry out a particular task.

Computer program is a set of instructions which directs computer to perform/carry out a particular task.

Computer and Program

Page 5: PLF Chapter1

Operation – define the series of actions to be followed by the computer

Order - specifies the logical arrangement of the operations

Data - the elements operated upon by the operations

Language – the medium by which the operations are communicated

Elements of Computer Program

Page 6: PLF Chapter1

1. Problem Analysis2. Program Design3. Program Coding4. Program Debugging and Testing5. Program Implementation and Maintenance

Program Development Process

Page 7: PLF Chapter1

It is the step wherein a good definition of the problem are considered and the program specification are developed.

Program specification is a document being prepared as a part of system design which contain the following:◦ Program Background◦ I/O Specifications◦ Program Methodology

Problem Analysis

Page 8: PLF Chapter1

It is the stage where logical sequence/ arrangement of operations for the solution have to be planned, consistent with the program specifications.

Algorithm is a written series of logical instructions which accomplish solution to a problem.

Algorithms are developed by using any of the program design tools such as structure charts, flowcharts, decision table, pseudo codes, etc.

Program Design

Page 9: PLF Chapter1

Commonly used program design tools:

◦ Structure/hierarchy chart - depicts the overall organization of a program, it shows how segments/modules are defined and how they relate to one another

Program Design Tools

Transaction_program

Input OutputProcess

Data

Sort Compute

Report

Figure 1.1 Example of Structure/hierarchy chart

Page 10: PLF Chapter1

◦ Flowchart – it shows graphical presentation of an algorithm

- also known by other names such as block diagram, logic diagram, run diagram, flow diagram and system chart

Program Design Tools

Start

Stop

Print (“Hello”)

Figure 1.2 Example of Flowchart

Page 11: PLF Chapter1

◦ Decision table – is a table showing the actions to be taken for different combinations of condition (conditions and actions)

◦ Pseudo codes – it describes the logical flow of the solution to a problem through the use of English–like statements (structured English)

Program Design Tools

Page 12: PLF Chapter1

Coding – is the process of writing the actual program steps in the proper format for a particular programming language

Factors that may affect the programming language used are:◦ Suitability◦ Integration◦ Standards◦ Portability◦ Development speed

Program Coding

Page 13: PLF Chapter1

Testing – refers to the process of verifying the accuracy or workability of the program

Debugging – refer to the process of locating/identifying and correcting the errors in the program

Two main types of errors:◦ Syntax error – occurs when the programmer has not

followed the rules of the programming language◦ Logic error – occurs when running a program produces

incorrect results

Program Testing and Debugging

Page 14: PLF Chapter1

Source code – a computer program before it is compiled

Object code – the machine language version of the computer program generated after the program source code is compiled

Compiler – is a system special software which translates a programming language into machine language and assembles the program to check errors upon correct usage of programming language

Testing and Debugging

Page 15: PLF Chapter1

It entails the preparation of a document describing how the program is constructed, together with all the significant resources surrounding its creation

This phase is performed at every stage of the program development such that an output of each development stage is documented

Program Documentation

Page 16: PLF Chapter1

It is the final stage of program development life cycle which involves running the system and updating the software as needed

Program continually be modified or revised to cope with changes and persistently be useful.

Program Implementation and Maintenance

Page 17: PLF Chapter1

“Programming languages were developed to facilitate communication between the user and the computer.”

Programming Language Era◦ Machine Language◦ Symbolic Language◦ High – level Language◦ Fourth Generation Language

Evolution of Programming Languages

Page 18: PLF Chapter1

It is the only language that computer can understand which consists of a string of ones and zeros (1s and 0s)

It is machine-dependent

Computer ready to execute it

Machine Language

Page 19: PLF Chapter1

Assembly language/Language processor – it enabled programmer to write instructions that used symbols, words or abbreviations which stand for certain operations

Assembler – it translate the assembly language into machine language

It is machine-dependent

Symbolic Language

Page 20: PLF Chapter1

Compiler/interpreter – it is a special software which act as language translator for high-level language

It is machine independent

The use of high-level language means lesser time in writing program

High – level Language

Page 21: PLF Chapter1

Some of the high-level programming languages:

◦ Fortran (Formula Translation) Started in 1954 by IBM Laboratory It is a scientific language used in research applications or

analysis of problems in science, engineering and sometimes in business

◦ Lisp (List Processing) Developed in 1958 Designed for the manipulation of symbols and patterns One of the most popular languages for Artificial

Intelligence

High – level Programming Languages

Page 22: PLF Chapter1

◦ Cobol (Common Business Oriented Language) Developed in 1959 by USA Army Designed for administrative purposes and among its

significant features are its file processing, editing, and I/O capabilities

◦ PL/1 (Programming Language 1) Developed in the middle of 1960s by IBM Characterized as general-purpose and procedural

applicable to business as well as scientific applications◦ Basic (Beginners All – purpose Symbolic

Instruction Code) Developed in 1965 by John Chimney and Thomas Kurt at

Dartmouth College, New Hampshire, USA Described as conversational, procedure-oriented and

general-purpose programming language

High – level Programming Languages

Page 23: PLF Chapter1

◦ Prolog (Programming in Logic) Developed in 1972 A logic-language based on logical rewrite systems

that can support artificial intelligence and expert system

◦ Pascal Named after Blaise Pascal, a brilliant 17th century

mathematician Designed by Niklaus Wirth at the Institute fur

Informatik in Zurich (1971) Intended as an instructional language

◦ RPG (Report Program Generator) Designed for programming business-oriented reports

High – level Programming Languages

Page 24: PLF Chapter1

◦ ADA Named after Lady Ada Byron Conceptualized in 1974 by the US Department of

Defense for military applications◦ C (Successor to B)

Designed by Dennis Ritchie during 1969 to 1971 One of the most powerful languages at all times

which is very well structured, powerful, portable, and flexible

◦ Smalltalk Developed at Xerox Palo Alto Research Center in

1972 An extreme object oriented language

High – level Programming Languages

Page 25: PLF Chapter1

◦ C++(C + 1 in the C language) Developed in 1985 at AT&T Bell Laboratory by Bjarne

Stroustrup One of the most popular object-oriented languages

◦ Java Developed in 1994 by James Gosling at Sun

Microsystems Combination of C++ and Smalltalk, developed to be

as portable as possible

High – level Programming Languages

Page 26: PLF Chapter1

It aims to make programming easier even to non-technical people

Three categories of Fourth Generation Language:◦ Database and Query Languages◦ Natural Languages◦ Intelligent Languages

Fourth Generation Language

Page 27: PLF Chapter1

Sources: NCC Text de la Rosa, Jerald H., Simple Program

Logic Formulation Fully Illustrated