Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENGR. SHOAIB ASLAM Computer Programming I Lecture 02.

Similar presentations


Presentation on theme: "ENGR. SHOAIB ASLAM Computer Programming I Lecture 02."— Presentation transcript:

1 ENGR. SHOAIB ASLAM Computer Programming I Lecture 02

2 Contents Computer Languages Machine Languages Algorithms Compiler Interpreter Assembler

3 Computer Languages What is a Language…? human beings communicate with each others in different language such as Urdu, French, Punjabi and Arabic etc. to communicate with the computers we have to use specific languages hundreds of languages have been develop in which few of them has gained international reputation. C language is one of them

4 TYPES Basically, languages are divided into two categories according to their interpretation. Low Level Languages High Level Languages Computer Languages

5 Low Level Languages Low level computer languages are machine codes or close to it. Computer cannot understand instructions given in high level languages or in English. It can only understand and execute instructions given in the form of machine language i.e. language of 0 and 1. There are two types of low level languages: Machine Language Assembly Language

6 Machine Language Lowest and most elementary level of Programming language First type of programming language to be Developed. It is basically the only language which computer Can understand. In fact, a manufacturer designs a computer to obey just one Language, its machine code, which is represented inside the computer by a String of binary digits (bits) 0 and 1. The symbol 0 stands for the absence of Electric pulse and 1 for the presence of an electric pulse. Since a computer is Capable of recognizing electric signals, therefore, it understand machine Language. Low Level Languages

7

8

9 Assembly Language Also low level but a very important language in which operation codes and operands are given in the form of alphanumeric symbols instead of 0’s and l’s. These alphanumeric symbols will be known as mnemonic codes and can have maximum up to 5 letter combination e.g. ADD for addition, SUB for subtraction, START,LABEL etc. Because of this feature it is also known as ‘Symbolic Programming Language’. Low Level Languages

10

11 Assembly Language (Cont..) This language is also very difficult and needs a lot of practice to master it because very small English support is given to this language. The language mainly helps in compiler orientations. The instructions of the Assembly language will also be converted to machine codes by language translator to be executed by the computer. Low Level Languages

12

13 High Level Language

14 User Friendly High level computer languages give formats close to English language Purpose of developing high level languages is to enable people to write programs easily and in their own native language environment (English). High-level languages are basically symbolic languages that use English words and/or mathematical symbols rather than mnemonic codes. Each instruction in the high level language is translated into many machine language instructions thus showing one-to-many translation

15

16

17

18 Types of High Level Languages 1. Algebraic Formula-Type Processing: computational procedures for solving mathematical and statistical problem i. BASIC (Beginners All Purpose Symbolic Instruction Code). ii. FORTRAN (Formula Translation). iii. PL/I (Programming Language, Version 1). iv. ALGOL (Algorithmic Language). v. APL (A Programming Language). 2. Business Data Processing: maintaining data processing procedures and files handling problems. i. COBOL (Common Business Oriented Language). ii. RPG (Report Program Generator

19 3. String and List Processing: These are used for string manipulation including search for patterns, inserting and deleting characters. Examples are: i. LISP (List Processing). ii. Prolog (Program in Logic). 4. Object Oriented Programming Language: In OOP, the computer program is divided into objects. Examples are: i. C++ ii. Java 5. Visual programming language: these are designed for building Windows-based applications Examples are: i. Visual Basic ii. Visual Java iii. Visual C Types of High Level Languages (Cont…)

20

21

22 Algorithms "a set of rules that precisely defines a sequence of operations” effective method expressed as a finite list of well-defined instructions for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing "output“ and terminating at a final ending state.

23 Algorithms (Cont…)

24

25 Expressing Algorithms Natural language expressions of algorithms tend to be verbose and ambiguous, and are rarely used for complex or technical algorithms. Pseudocode, flowcharts and control tables are structured ways to express algorithms that avoid many of the ambiguities common in natural language statements. Programming languages are primarily intended for expressing algorithms in a form that can be executed by a computer, but are often used as a way to define or document algorithms. Algorithms (Cont…)

26

27 In computer systems, an algorithm is basically an instance of logic written in software by software developers to be effective for the intended "target" computer(s) for the target machines to produce output from given input. Algorithms (Cont…)

28

29 Compiler A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program.

30 Compilers bridge source programs in high-level languages with the underlying hardware. A compiler requires ; i. determining the correctness of the syntax of programs, ii. generating correct and efficient object code, iii. run-time organization, iv. formatting output according to assembler and/or linker conventions. Compiler (Cont…)

31

32 Structure of Compiler The front end checks whether the program is correctly written in terms of the programming language syntax and semantics. Errors are reported if any, in a useful way. The frontend then generates an intermediate representation or IR of the source code for processing by the middle-end. The middle end is where optimization takes place. Typical transformations for optimization are removal of useless or unreachable code, discovery and propagation of constant values, relocation of computation to a less frequently executed place (e.g., out of a loop), or specialization of computation based on the context. The back end is responsible for translating the IR from the middle- end into assembly code. The target instruction(s) are chosen for each IR instruction. Register allocation assigns processor registers for the program variables where possible Compiler (Cont…)

33

34 Interpreter Computer program that executes, i.e. performs, instructions written in a programming language. An interpreter generally uses one of the following strategies for program execution:  execute the source code directly  translate source code into some efficient intermediate representation and immediately execute this  explicitly execute stored precompiled code made by a compiler which is part of the interpreter system

35

36 Interpreter VS Compiler Programs are usually written in high level code, which has to be converted into machine code for the CPU to execute it. This conversion is done by either a compiler or an interpreter. A compiler makes the conversion just once, while an interpreter typically converts it every time a program is executed (or in some languages like early versions of BASIC, every time a single instruction is executed).

37

38 Assembler A computer program which translates from assembly language to an object file or machine language format. An assembler creates object code by translating assembly instruction mnemonics into opcodes, and by resolving symbolic names for memory locations and other entities. The use of symbolic references is a key feature of assemblers, saving tedious calculations and manual address updates after program modifications

39

40

41 Data & Information Facts, figures, values, pictures in raw form Information: Facts, figures, values, pictures in well organized form

42 TypeExplanationTypeExplanation char smallest addressable unit of the machine that can contain basic character set. It is an integer type. Actual type can be either signed or unsigned depending on implementation signed char same as char, but guaranteed to be signed. unsigned char same as char, but guaranteed to be unsigned. short short int signed short signed short int short signed integer type. At least 16 bits in size. unsigned short unsigned short int same as short, but unsigned. int signed int basic signed integer type. At least 16 bits in size. unsigned unsigned int same as int, but unsigned. long long int signed long signed long int long signed integer type. At least 32 bits in size. unsigned long unsigned long int same as long, but unsigned. long long long long int signed long long signed long long in t long long signed integer type. At least 64 bits in size. unsigned long long unsigned long long i nt same as long long, but unsigned. float (single precision) floating- point type.

43 double double precision floating-point type. long double extended precision floating-point type.


Download ppt "ENGR. SHOAIB ASLAM Computer Programming I Lecture 02."

Similar presentations


Ads by Google