ALGORITHMS AND PROGRAMMING LANGUAGES Networks and Communication Department

  • Slides: 19
Download presentation
ALGORITHMS AND PROGRAMMING LANGUAGES Networks and Communication Department Lecture 5: Algorithms and programming languages

ALGORITHMS AND PROGRAMMING LANGUAGES Networks and Communication Department Lecture 5: Algorithms and programming languages

Algorithm An algorithm is a procedure or formula for solving a problem. Derives from

Algorithm An algorithm is a procedure or formula for solving a problem. Derives from the mathematician, Mohammed ibn. Musa al-Khwarizmi. Al-Khwarizmi's work is the likely source for the word algebra as well.

Definition: In mathematics and computer science, an algorithm is a step-by-step procedure for calculations.

Definition: In mathematics and computer science, an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning. A program is one type of algorithm All programs are algorithms Not all algorithms are programs!

Programming Language

Programming Language

Programming Language A programming Language is a notational system intended primarily to facilitate human-machine

Programming Language A programming Language is a notational system intended primarily to facilitate human-machine interaction. The notational is understood both by human and machine. The programming language has Syntax, and language elements have Semantics.

What is a program? A program is something that is produced using a programming

What is a program? A program is something that is produced using a programming Language. A program Semantics. is a structured entity with

What is programming?

What is programming?

What is programming? Programming is a Science: Because it implement the algorithms describe by

What is programming? Programming is a Science: Because it implement the algorithms describe by mathematics and science. Programming is a Skill: Because it requires design efforts. Programming is an Engineering: Because it requires a tradeoffs between program size, speed, time (required for development and debugging) and maintainability among many solutions. Programming is an Art

Types of programming Languages

Types of programming Languages

Levels of Programming Languages High-level program class Triangle {. . . float surface() return

Levels of Programming Languages High-level program class Triangle {. . . float surface() return b*h/2; } Low-level program LOAD r 1, b LOAD r 2, h MUL r 1, r 2 DIV r 1, #2 RET Executable Machine code 000100100101 0010010011101100 10101101001. . .

CSC 141 Introduction to Computer Programming Levels/Generations of Programming Languages 1 st Generation Programming

CSC 141 Introduction to Computer Programming Levels/Generations of Programming Languages 1 st Generation Programming language (1 GL) � Machine Language: 0 s or 1 s 2 nd Generation Programming language (2 GL) � Assembly Language : Mnemonics 3 rd Generation Programming language (3 GL) � High-Level Languages ; (procedure oriented or Object Oriented) 4 th Generation Programming language (4 GL) � Very-High-Level Languages 5 th Generation Programming Language � Natural Languages

Machine language (1 GL) The lowest level of language. The language used to program

Machine language (1 GL) The lowest level of language. The language used to program the firstgeneration computers. The instructions in 1 GL are made of binary numbers, represented by 1 s and 0 s correspond to the on and off states of electrical switches. Suitable for the understanding of the machine but very much difficult to interpret and learn by the human programmer.

CSC 141 Introduction to Computer Programming Assembly language (2 GL) Low-level language that allows

CSC 141 Introduction to Computer Programming Assembly language (2 GL) Low-level language that allows a programmer to use abbreviations or easily remembered words instead of numbers. These Observations are called Mnemonics. These Mnemonic are Opcode and Operands For Example: ADD AX, BX MOV CX, AX INC CX Op-code; ADD, MOV, INC Operands AX, BX, CX

CSC 141 Introduction to Computer Programming Assembly language (2 GL) • • • Programmer

CSC 141 Introduction to Computer Programming Assembly language (2 GL) • • • Programmer can write instructions faster but it is still not an easy language to learn. Drawback: The language is specific to a particular processor family and environment. (Assembler – A program that translates the assembly language program into machine language.

High Level languages (3 GL) A High-Level Language is an English-like language. It is

High Level languages (3 GL) A High-Level Language is an English-like language. It is a refinement of a second-generation programming language. It allowed users to write in familiar notation, rather than numbers or abbreviations. Most High-level languages are not Machine Dependent. Translator for High-level languages is either a Compiler or an Interpreter. Examples of High-level languages: ― FORTRON ― COBOL ― BASIC

Very-High-Level Languages (4 GL) 4 GLs are much more user-oriented and allow programmers to

Very-High-Level Languages (4 GL) 4 GLs are much more user-oriented and allow programmers to develop programs with fewer commands compared with 3 GLs. Non-Procedural Language; Programmers don’t have to specify all the programming logic, only tell the computer what they want done. Saves a lot of time. 4 GLs consist of report generators, query languages, application generators, and interactive database management system For example:

Natural Languages (5 GL) Two types � Ordinary Human Languages; like English. � Programming

Natural Languages (5 GL) Two types � Ordinary Human Languages; like English. � Programming language that use human language to give people a more natural connection with computers. 5 GLs are designed to make the computer solve a given problem without the programmer. Natural languages are part of the field of study known as Artificial Intelligence. � Develop machines to emulate human-like qualities such as learning, reasoning, communicating, seeing and hearing.

Any Questions ? 18 Networks and Communication Department

Any Questions ? 18 Networks and Communication Department

References Behrouz Forouzan and Firouz Mosharraf, “Foundations of computer science”, Second edition, chapter 18,

References Behrouz Forouzan and Firouz Mosharraf, “Foundations of computer science”, Second edition, chapter 18, pp. 466 -490 Networks and Communication Department