Presentation on theme: "INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols."— Presentation transcript:
Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols and Uses) Difference between Pseudo Code and Flowchart Stages of Program Development Process Low Level Languages (Machine language and Assembly language) Cont’d…..
Programming Languages High Level Languages (Procedural, Object-Oriented and Non-Procedural) Advantages and Disadvantages of High-Level Languages Language Processors: Compiler, Interpreter, and Assembler
Program It is a set of instructions that tells a computer what to do, computer works according to the given instructions in the program. Computer programs are written in programming languages. The programmer develops programs to instruct the computer how to process data to convert into information. Programmers use programming languages and tools to write programs.
Algorithms and Pseudo Code An algorithm is a step by step procedure to solve a problem. It is better to write algorithm before writing the actual computer program. Properties of an Algorithm Its properties are: The given problem should be broken into simple and meaningful steps. The steps should be numbered sequentially. The steps should be descriptive and written in simple English.
Algorithms and Pseudo Code Algorithms are written in a language, which is similar to simple English. This language is known as Pseudo language. Pseudo code is used to specify program logic in an English like manner that is independent of any particular programming language. This simplifies program development by separating it into two main parts: Logic Design and Coding. Logic Design – Logic of the program is designed, we specify different steps required to solve the problem and the sequence of these steps.
Algorithms and Pseudo Code Coding – The algorithm is converted into a program, the steps of algorithm are translated into instructions of any programming language. Example: Algorithm accepts two numbers from the user, calculates its sum and then displays the result. 1. Input A, B 2. Total = A + B 3. Display Total 4. Exit
Algorithms and Pseudo Code Advantages of Algorithm Reduced Complexity – while writing the algorithm we can focus on solving the problem instead of concentrating on a particular language. Increased Flexibility – Algorithm is written so that the code may be written in any language that is Visual Basic, Java, C++ etc. Ease of Understanding – You don’t have to understand a particular programming language to understand an algorithm, as it is written in English like manner.
Flowchart It is the combination of two words: Flow and Chart. Chart consists of different symbols to display information about any program. Flow represents the direction of processing that takes place in the program. Flowchart is the graphical representation of an algorithm, that is used to show all the steps of an algorithm in a sequence. An algorithm is first converted to a flowchart to show its steps graphically, then it is converted into a program.
Uses of Flowchart To represent an algorithm in simple graphical manner. To show the steps of an algorithm in an easy way. To understand the flow of the program. To improve the logic for solving a problem. Programs can be reviewed and debugged easily.
Flowchart Symbols Input/Output – Parallelogram symbol is used to represent an input or output Process – Rectangle symbol is used to represent a process step, that may be a complex calculation or simply an assignment statement. Selection – Diamond symbol is used to represent selection step, a condition is given in the diamond. The flow of control from diamond may go in two directions, one direction for true condition and the other is for false condition. Start/End – Oval symbol is used to represent the start and end of the flowchart.
Flowchart Symbols Flow lines– Arrow symbols are used to represent the direction of flow in the flowchart, they are of four types: UP, Down, Left and Right. Connector – Circle symbol is used to combine different flow lines, it is used when two or more flow symbols come from different directions and move to one direction. INPUT / OUTPUT PROCESSSELECTION START / END CON
Flowchart Symbols INPUT A, B SUM = A + B END START DISPLAY SUM FLOWCHART FOR ADDING TWO NUMBERS
INPUT MARKS END START DISPLAY “FAIL” MARKS>=40 DISPLAY “PASS” NO YES FLOWCHART FOR YES OR NO CONDITIONS
Difference between Pseudo Code & Flowchart FlowchartPseudo Code Flowchart contains standard symbols to represent different computer operations. There is no standard for writing pseudo code. Flowchart is less frequently used as it takes more time to design. Pseudo code is more frequently used as it takes less time. It is difficult to modify.It is easier to modify. It is a graphical representation of solution. It is not a graphical representation of solution.
Defining and Analyzing the Problem A programmer studies the problem and decides the best way to solve it, the study is based on: Facts and figures necessary for developing the program. The way in which the program will be designed. The language the program will be most suitable. The desired output with its required form. Designing the Algorithm The programmer designs algorithm to help visualize possible alternatives in a program. Stages of Program development Process
Coding or writing the program The next step after designing the algorithm is to write the program in a high – level language, called as Coding. Test Execution The process of executing a program to find out errors or bugs is called test execution. It helps the programmer to check the logic of the program. It also ensures that the program is error – free and workable. Stages of Program development Process
Debugging It is a process of detecting, locating and correcting the bugs in a program, it is performed by running the program again and again. Final Documentation It guides the user how to use the program in the most efficient way. Another purpose is to allow some other programmer to modify the code if necessary. Documentation should be done in each step during development of a program. Stages of Program development Process
A set of words, symbols and codes used to write programs is called programming language. There are two types of Programming languages: Low – Level Languages and High – Level Languages. Low – level languages are near to computer hardware and far from human languages. Writing a program in low-level languages requires a deep knowledge of the internal structure of computer hardware. Examples: Machine language and Assembly language. Low - Level Languages
Machine language A type of language in which instructions are written in binary form is called machine language. It is the only language that is directly understood by the computer, it also called fundamental language. Program written in machine language can be executed very fast by the computer. Programs written in machine language are machine dependent, every computer has its own machine language. Low - Level Languages
Machine language is difficult to understand, writing and modifying a program in this language takes a lot of time. Machine language is also known as First generation language. Assembly Language It is one step higher than machine language, in which symbols (mnemonics), are used instead of binary code. Example: SUB instruction is used to subtract two numbers. Low - Level Languages
Assembly language is also called Symbolic language, its programs are easier to write and modify than a machine language. Assembly language is mostly used for writing system software. It is also known as Second generation language. Low - Level Languages
It is a type of language that is close to human languages is called high – level languages are easy to understand. Instructions of these languages are written in English – like words such as input and print etc. A program written in high – level language is easier to write and modify. High – level languages are further divided into following categories: Procedural Languages Object – Oriented Languages Non – Procedural Languages High - Level Languages
Procedural Languages These languages are also known as third – generation languages or 3GL. In these languages, a program is a predefined set of instructions, computer executes these instructions in the same sequence in which these instructions are written. Each instruction in this language tells the computer what to do and how to do. Procedural languages have many advantages over machine and assembly languages such as: High - Level Languages
Program statements are similar to English and are easy to learn. Less time is required to write programs. Programs are easier to understand and modify. Some disadvantages of Procedural languages over machine and assembly languages are: Program execute more slowly. Language use computer resources less efficiently. Most popular Procedural languages FORTRAN – stands for FORmula TRANslation, mainly used for engineering applications and scientific use. High - Level Languages
BASIC – stands for Beginners All purpose Symbolic Instruction Code, it was created in the late 1960. It was used mainly by students to use the computer for solving simple problems. It is easy to understand and is widely used for education purpose. COBOL – stands for Common Business Oriented Language, that is specially designed for business applications. It was developed in early 1960s, its programs are lengthy but easy to read, write and maintain. High - Level Languages
C – It is a popular high – level language, developed by Dennis Ritchie at AT&T Bell laboratories. It was written as part of UNIX operating system, it is also known as middle – level language because it provides the facilities to write application software as well as system software. Object – Oriented Languages OOP is a technique in which programs are written on the basis of objects, that is a collection of data and functions. High - Level Languages
Object may represent a person, thing or place in real world. In OOP data and all possible functions on data are grouped together. These programs are easier to learn and modify, C++ and Java are two most popular Object – Oriented languages. Example: a person can be an object, which has some properties such as Name, Age, and Height etc. It also has some functions such as Walk, Talk, and Eat. High - Level Languages
C++ - is an object oriented language, it was developed in 1980 at Bell Laboratories. It is an improved version of C language, that provides the facility of working with objects and classes. It is very powerful language and is used to develop a variety of programs. Non – Procedural Languages These are also known as fourth generation languages or 4GL, in which user only needs to tell the computer “what to do” not “how to do”. High - Level Languages
An important advantage of non – procedural languages is that they can be used by non – technical user to perform a specific task. These languages accelerate program process and reduce coding errors. 4GL are normally used in database applications and report generation. SQL – stands for Structured Query Language, it is the most popular database query language, developed by IBM. High - Level Languages
It is a national standard by the American National Standards Institute (ANSI). SQL works with database programs like MS Access, DB2, Informix, MS SQL Server, Oracle, Sybase etc. RPG – stands for Report Program Generator, was developed in early 1960s by IBM. It is used to generate business reports, and mostly used with IBM mid – range computers. High - Level Languages
Easy to learn – as these are closer to human languages therefore these languages are easier to learn than low – level languages. Machine Independence – A program written for one type of computer system can be executed on a different computer as these languages are machine independent. Program libraries – Program libraries are the collection of reusable program codes, which can be reused by any programmer for writing programs more easily in less time. Advantages of High - Level Languages
Easy error detection – as these languages are easy to read and modify, therefore it is very easy to find errors in programs. Standardized Syntax – these languages have standardized syntaxes which is determined by ANSI. More programmers – It encourages more people to learn these languages, so many programmers of high-level languages are available. Shorter Programs – their programs are shorter than low – level languages, as one instruction in high – level language is equivalent to many instructions of low – level language. Advantages of High - Level Languages
Translator required – these programs can not run directly as computer hardware does not understand them, so a language translator is required to convert these programs into machine language. Time consuming execution – these programs are first translated into machine code and then executed, so the execution takes more time. Less Hardware support – these languages provide less support for writing hardware level programs, as these languages are normally used for writing application software. Disadvantages of High - Level Languages
Compiler It is a program that converts the instructions of high – level language into machine language as a whole. A program written in high level language is called Source program. Compiler converts Source program into machine code known as Object program. Compiler checks each statement in the source program and generates machine instructions. It also checks syntax errors, a source program containing an error cannot be executed. Language Processors
A compiler can translate the programs of only that language for which it is written. Example: C compiler can translate only C language programs. Language Processors Compiler Source Program Object Program
Interpreter It is a program that converts one statement of a program at one time and executes it before translating the next statement of the source program. If there is an error in the statements, the interpreter stops working and displays an error message. The advantage of interpreter over compiler is that an error is found immediately, so the programmer can correct errors during program development. Its disadvantage is that it is not very efficient, as it does not produce any object program, eg. Visual Basic uses interpreter. Language Processors
Assembler An assembler is used to translate the instructions of assembly language into machine language. Language Processors Assembler Assembly language Program Object Program