Presentation is loading. Please wait.

Presentation is loading. Please wait.

KIM, MCA Programme, kalol

Similar presentations

Presentation on theme: "KIM, MCA Programme, kalol"— Presentation transcript:

1 KIM, MCA Programme, kalol
Sub: : Fundamental of Programming(FOP) Chap: 1 : Introduction to Programming: Algorithms and Flowcharts Presented By Tejas Modi Asst. Professor, KIM, MCA Programme, kalol TEJAS MODI

2 Chap: 1 : Introduction To Programming
Program and Programming Programming Language Compiler, Interpreter The Process of Compilation Linker, Relocation, Loader Generation of Languages Classification of Programming Languages Algorithms Flowcharts TEJAS MODI

3 Program and Programming
A program is set of logically related instruction that arranged in a sequence and guides the computer in solving a problem. Programming The process of writing a program is called programming. There are two ways in which one can acquire a program. Packaged Software Customized Software TEJAS MODI

4 Computer Software Computer Software can classified into two categories
System Software: it is a collection of programs that interface with the hardware. Application Software: it is written to enable the computer to solve a specific data processing task. Computer Software System Software Application Software Language Translator Operating System Utilities Special purpose Program (Loader, Linker) Pre – Written Software User – Written Application TEJAS MODI

5 Programming Language System Programming Languages
A programming language is composed of a set of instruction in a language understandable to the programmer and recognizable by a computer. System Programming Languages O.S. Application Programming Languages Business and Scientific application, Payroll, inventory etc. Low-level Languages: Machine Language (Machine Code) Assembly language (Mnemonic Code) High-level Language Basic C COBOL (Common Business Oriented Programming Language) FORTRAN (Formula Translation Language) TEJAS MODI

6 Compiler, Interpreter, Loader, Linker
A high level program source code transfer into a form of machine under standable code, this process is done by compiler. It is Software. Diagnostics The process of translating, the compiler the source program statement wise and check for errors. In case of any error, the computer generates a printout of same, this action is known as diagnostic. Interpreter is another type of translation software. Source Program in High Level Compiler Object Code in Machine Language TEJAS MODI

7 Difference between Compiler Interpreter
Scans the entire program before translating it into machine code. Convert the entire program to machine code and only when all the syntax errors are removed does execution take place. Slow in debugging, i.e. removal of mistakes from a program. Execution time is less. Interpreter Translates and executes the program line by line. Each time the program is executed, every line is checked for syntax error and the converted to the equivalent machine code. Good for fast debugging. Execution time is more. TEJAS MODI

8 Compiling and Executing High level Language program
It consists two step Analysis of the source program. Synthesis (creation) of the object program in the machine language of specific machine. A Source language is described using lexical rules, syntax rules and semantic rules. Lexical rules specify the valid syntactic element or word of language. (identifier, operator delimiter etc.) Syntax rules specify the way in which valid syntactic elements are combined to form the statements of language. Syntax rules are often described using a notation known BNF (Backus Naur Form) grammar. Semantic rules assign meanings to valid statements of language. TEJAS MODI

9 The Process of Compilation
Source Program Lexical Analysis Syntactic Semantic Symbol Table Other Tables Code Generator Linker and Loader Lexical Rules Syntax Rules Semantic Rules Intermediate code Object Code Executable Code Object Code from Other Compilations TEJAS MODI

10 Linker & Loader Linker Loader Linking Loader and Linkage Editor
Linking resolves symbolic references between object program. Linking of the translated program with other object programs needed for execution. Loader Loader means physically placing the machine instruction and data into main memory. A loader is a system program that accepts object programs and prepares them for execution and initiates the execution. The function of the loader are as follows: Assignment of load-time storage area to the program. Loading of program into assigned area. Relocation of program to executed properly from its load time storage area. Linking of programs with one another. A loader is program that places a program’s instruction and data into primary storage (RAM) locations. Linking Loader and Linkage Editor The machine language program produced by the translator must normally be combined with other machine language program residing within the library to form a useful execution unit. This process of program combination is called linking and the software that performs this operation is variously known as linking loader or a linkage editor. TEJAS MODI

11 Generation of Languages
The 1GL are low – level languages that are machine language. The 2GL are also low-level languages that generally consist of assembly languages. The 3GL are high – level such as C. The 4GL are languages that consist of statements similar to statements in a human language. Fourth generation languages are commonly used in database programming. The 5GL are programming language which is based around solving problems using constrains given to the program, rather than using an algorithm written by a programmer. Most constraint-based and logic programming languages and some declarative languages are fifth-generation languages. A good example of a fifth generation language is artificial intelligence research. Prolog, OPS5(Official Production System), and Mercury are examples of fifth-generation languages. TEJAS MODI

12 Classification of Programming Languages
High – level Languages Low – level Languages Algorithmic (COBOL, FORTAN, C ) Procedural Non - Procedural Problem Oriented Object Oriented ( C++, Java ) Scripting ( VB, PERL ) Functional ( LISP, ML ) Logic Based ( PROLOG ) Numerical ( MATLAB ) Symbolic ( MATHEMATICA ) Publishing ( LATEX ) TEJAS MODI

13 Structure Programming
Structure programming can be defined as a Top – down analysis: Subdivision of a problem (First we solve smaller problem) Hierarchy of tasks Modular Programming: It is a program that is divided into logically independent smaller section. Structure Code: It is a method of coding, i.e. writing a program that produce a well organized module. (Never use GOTO). A high level language support some structured control statement. The process of Programming: Understand the problem to be solved Think & design the solution logic Write the program in chosen programming language Translate the program into machine code Test the program with sample data Put the program into operation TEJAS MODI

14 Algorithms Example of an algorithm, for making a pot of tea
An algorithm is a part of the plan for computer program, an algorithm is ‘an effective procedure for solving a problem in a finite number of step’. Example of an algorithm, for making a pot of tea Key feature of an algorithm Sequence (also known as process): each step or process in the algorithm is executed in the specified order. Decision (also known as selection): outcome of the decision is based on some condition. Repetition (also known as iteration or looping) Variables A variable is a data name that may be used to store data value. Variables and data types Numerical Alphabetic Logical data TEJAS MODI

15 Algorithms Different ways of Starting Algorithms Step-form:
Step-form is in written form, the written form is just normal language. Ex: Construct a algorithm for interchange the numeric value of two variable 1. START A=B 2. PRINT “ENTER THE VALUE OF A & B” 6. B=C 3. INPUT A, B PRINT A, B 4. C=A END Pseudo-Code Pseudo-code is also in human language but tends toward more precision by using a limited vocabulary. It is similar to 3GL. There is no standard for pseudo-code, it is generally quite easy to read and use. Ex: dowhile kettle_empty Add_water_to _kettle end dowhile TEJAS MODI

16 3. Flowcharts A flowchart provides appropriate step to be followed in order to arrive at solution to a problem. It is a program design tool which is used before writing the actual program. Flowchart are generally developed in the early stages of formulating computer solution. Standards for Flowcharts Flowcharts must be drawn on white, unlined 81/2” x 11” paper, on one side only. Flowcharts start on the top of the page and flow down and to right. Only standard flowcharting symbols should be used. A template to draw the final version of flowchart should be used. The contents of each symbols should be printed readable. English should be used in flowchart, not programming language. The flowchart for each subroutine, if any must appear on a separate page. Each subroutine begins with a terminals symbols with the subroutine name and a terminal symbols labeled return at the end. Draw arrow between symbols with a straight edge and use arrowheads to indicate the direction of the logic flow. TEJAS MODI

17 Flowcharts Symbols Start or end of the program of flowchart Flow lines
Add Comments or furnish clarifications Computational steps or processing Function of a program Input entry or Output display operation Decision making and branching operation Connects remote parts of flowchart on the same page A magnetic Tape A magnetic Disk Connects remote portion of the flowchart not on the same page Flow lines Start or end of the program of flowchart Display TEJAS MODI

18 Flowcharts Guidelines for flowcharting:
There should be logical Start and Stop. Flow is from left to right or top to bottom. Only one flow line should emerge from a process symbol. Only one flow line should enter a decision symbol. Only one flow line is used in conjunction with a terminal symbol. If the flowchart becomes complex, connector symbols should ne used In decision symbol only one input indicated by one incoming flow line and one output flowing out. The decision and process symbol are connected by flow lines. Iteration or looping is depicted by a combination of process and decision symbols placed in proper order. TEJAS MODI

Ex: Give 5% bonus to employee whose salary is >5000 otherwise give Rs 250 as a bonus. START INPUT SALARY OF AN EMPLOYEE IS SAL>=5000 BONUS=0.05*SALARY BONUS=250 PRINT BONUS STOP

20 Flowcharts Advantages Limitations
Communication : Flowcharts are a better way of communicating the logic of a system to all concerned Effective Analysis: With flowcharts, problem can be analyzed more effectively. Proper Documentation : Program flowcharts serve as a good program documentation needed for various purposes. Efficient Coding: Flowcharts act as a guide or blueprint during the systems analysis and program development phase. Proper Debugging: Flowcharts help in the debugging process. Efficient Program Maintenance : The maintenance of an operating program becomes easy with the help of a flowcharts Limitations Complex logic: The program logic is quite complicated. In such a case, a flowchart become complex and clumsy. Alterations and modifications: If alterations are required, the flowchart may need to be redrawn completely. Reproduction: Since the flowcharts symbols cannot be typed in, the reproduction of a flowchart become a problem. TEJAS MODI


Download ppt "KIM, MCA Programme, kalol"

Similar presentations

Ads by Google