Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Language Concepts & Its Applications

Similar presentations


Presentation on theme: "Programming Language Concepts & Its Applications"— Presentation transcript:

1 mali@uofk.edu Programming Language Concepts & Its Applications
Mahmoud Ali Ahmed Dean Faculty of Mathematical Sciences, U. of K.

2 Aims provides students with general idea about the computer programming. Gives background about how programming languages started and developed. Provides students with a preliminary introduction about computer programming applications Introduces C++ programming language and explain how practically it can be used (computer lab).

3 - Programming languages common concepts (Syntax and Semantics)
Contents - History of programming languages - High level : structure and object oriented programming - Programming languages common concepts (Syntax and Semantics) - Study in details selective programming language (C++)

4 Suggested readings - Concepts in Programming Languages, 3rd. ed John C. Mitchell. - Concepts of Programming Languages Robert W. Sebesta. - Programming Languages, 2nd ed Allen B. Tucker - Programming Languages Landscape, 2nd ed Michael Marcotty & Henry ledgard.

5 Suggested readings -continue
- سي ++ لغة البرمجة الحديثة . اسامة الحسين - Object Oriented Programmin in C++ , Richard Johnsonbaugh & Martin Kalin. - C++ and Object Oriented programming Paradigm, Debasish - Other Resources (Internet).

6 Computer System Components
As general computer system divided into two parts: 1. Hardware 2. Software

7 Software software is a collection of instructions and commands that used to perform a specific task through the computer (hardware).

8 Programming Language software
Software can be divided into three major types: System Software Application Software Programming Language software

9 Programming Language Software
It is a collection of instructions, symbols and rules that used to write a program (code) to perform specific job Programming languages can be divided into:

10 Machine Language Assembly Language High Level Language

11 High Level Language Write, Read, Print, Scan, and others.
It is a collection of symbols, numbers and word written in away similar to the human language such as Write, Read, Print, Scan, and others.

12 Each language follows its syntactic and semantic rules
Unlike other languages, high level languages are very simple , therefore they are useful languages There are so many high level languages, which will be discussed later.

13 To write any computer program, it should initially studied through what is known an algorithm
An algorithm is considered as the first step for writing computer program The word “algorithm” comes from the name of the famous Arabic mathematician Abu Jafar Mohammed ibn Musa Al Khawarizmi (825).

14 Any program (code) based on the following idea
Input Process Output

15 As mentioned an algorithm is the first step for writing computer program
An algorithm is a precise ordered list of unambiguous steps. Algorithms are often used to be represented by a flowcharts as

16 Open the lock Switch on the car Drive the car
car is locked Is the key there? No Bring the key Yes Open the lock Switch on the car Drive the car

17 Based on the concept that any algorithm should follow:
Input Process Output

18 The repetitive step, and
The structure of the algorithm can be shown in a set of steps: The input step. The assignment step. The decision step. Process The repetitive step, and The output step.

19 The input step The input step, specifies the operands that involve in solving the problem. The assignment step The assignment step, assigns operands values or other operand values. The decision step The decision step, specifies which next step should be followed among the alternatives.

20 The repetitive step The output step Note:
Also called the iteration step, specifies whether an operation needed to be repeated or iterated so many times (known or unknown). The output step The output step, specifies what is the result that should be achieved after completing all algorithms operations and processes. Note: Any algorithm should have start and end steps

21 Example #1 Write an algorithm that can be used to compute the area of a rectangle: Solution: the area of the rectangle is given by:

22 Solution Start 2. Input l , w 3. Compute A = l * w 4. Print A 5. Stop

23 Example #2 Solution: the average mark is given by:
Write an algorithm that can be used for computing the average mark for student who has six subjects: Solution: the average mark is given by: Average = (sub1+sub2+sub3+sub4+sub5+sub6)/6

24 Solution Start 2. Input s1, s2, s3, s4, s5, s6
3. Compute A = (s1+ s2+ s3+ s4+ s5+ s6 )/6 4. Print A 5. Stop

25 Example #3 Write an algorithm that can be used to compare two numbers and print out the greatest one. Also print out their difference if it is greater than the smallest one.

26 Solution Start 2. Input A , B 3. If A > B Goto 4 Else Goto 6
4. Compute D = A - B 5. If D > B Goto 8 Else Goto 10 6. Compute D = B - A 7. If D > A Goto 12 Else Goto 14 8. Print A, D

27 continue 9. Goto 15 10. Print A Goto 15 12. Print B, D 13. Goto 15
15. Stop

28 Example #4 Write an algorithm that can be used to find out the sum of following series.

29 Solution (For Loop) Start 2. Assign Sum = 0 3. Loop: For (I = 2, 1024)
4. Compute Sum = Sum + I 5. Compute I = I * 2 6. Repeat (Goto Step 3) 7. Print Sum 8. Stop

30 Solution (While Loop) Start 2. Assign Sum = 0, I = 2
3. Loop: While (I <= 1024) 4. Compute Sum = Sum + I 5. Compute I = I * 2 6. Repeat (Goto Step 3) 7. Print Sum 8. Stop

31 Flow Chart The symbols are: Start/End symbol 2. Input symbol
It is way to represent the algorithm graphically, through set of defined symbols. The symbols are: Start/End symbol 2. Input symbol

32 3. Data flow 4. Process 5. Decision 6. Output 7. Connector

33 Example #5 Draw a flow chart for Example #1 Start Input l , w A = l * w Print A Start

34 Draw a flow chart for Example #3 Start
Input A , B is A>B No Yes B D = A - B A

35 A is D>B Yes No Print A, D Print A C

36 B D = B - A is D>A No Yes Print B, D Print B C End

37 Quiz Write an algorithm that can be used to solve the following equation: Print out the result if it is greater than zero. Draw the flow chart.

38 Assignment To be submitted next week (Thursday 9/2/2015).

39 a. Write an algorithm that can be used to solve the following equation:
Print out the result if it is greater than or equal to zero. Draw the corresponding flow chart.

40 b. Write an algorithm that can be used to compare three numbers and print out the smallest one. Draw the corresponding flow chart

41 PROGRAMMING LANGUAGE HISTORY
Hundreds of programming languages have been designed and implemented over the last 50 years. As many as 50 of these programming languages contained new concepts, and useful features The history of modern programming languages begins around with the development of Fortran, Algol, Cobol, and Lisp, and later C, C++, and Java.

42 Assembly add bx, 4 cmp [adr], 3 jmp address
Assemblers exist since the beginning of computers (1950’s). They associate a symbolic name to the machine-language code, for example: add bx, 4             cmp [adr], 3        jmp address

43 Fortran - 1954-1958 FORmula TRANslator Language
Dedicated to mathematical calculations (ease the use of the ordinary mathematical notation in expressions). Fortran II (1958) introduced SUB-ROUTINES, FUNCTIONS, LOOPS, a primitive FOR control structure.

44 Algol - 1958 ALGOrithmic Language
Originally known as the IAL (for International Algorithmic Language.) It was designed to avoid some of the perceived problems with FORTRAN and eventually gave rise to many other programming languages (including Cobol and C).

45 ALGOL introduced code blocks and was the first language to use begin end pairs for delimiting them.
COBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. Cobol defines its primary domain in business, finance, and administrative systems for companies and governments.

46 LISP - 1958 LISt Processing Language
The Lisp programming language was developed at MIT in the late 1950s for research in artificial intelligence (AI) and symbolic computation. The strength of Lisp is its simplicity and flexibility.

47 C C is a general-purpose, cross-platform, block structured, and procedural, programming language developed for use with the Unix operating system. Although it was designed for implementing system software, it is also widely used for developing application software.

48 C C++ (C Plus Plus) is a general-purpose programming language. The language was developed as an enhancement to the C programming language and originally named "C with Classes”. It is considered as a middle-level language, as it comprises a combination of both high-level and low-level language features.

49 Java Java is a programming language originally developed and released in The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java code has so many features: use the object-oriented programming methodology, allow the same program to be executed on multiple operating systems, contain built-in support for using computer networks, and others.

50 As general, languages are classified into procedural and nonprocedural languages
Procedural languages are used in the traditional programming that is based on algorithms or a logical step-by-step process for solving a problem (Examples are FORTRAN, COBOL, ALGOL, C). Non-procedural programming languages allow users and professional programmers to specify the results they want without specifying how to solve the problem (Examples are C++ and Java). Also known as Object Oriented Programming Language (OOP), uses the concepts of classes and objects.

51 Syntax and Semantics of Programming Languages
Many of the methods and much of the terminology of linguistics apply to programming languages. 1. Syntax refers to the ways symbols may be combined to create well-formed sentences (or programs) in the language. Syntax defines the formal relations between the elements of a language, thereby providing a structural description of the various expressions that make up legal strings in the language.

52 Syntax deals only with the form and structure of symbols in a language without any consideration given to their meaning. 2. Semantics reveals the meaning of syntactically valid strings in a language. For programming languages, semantics describes the behavior that a computer follows when executing a program in the language.

53 This behavior might be revealed by describing the relationship between the input and output of a program or by a step-by-step explanation of how a program will execute on a real machine.

54 Error Messages Bug: A mistake in a program
The process of eliminating bugs is called debugging Syntax error: A grammatical mistake in a program The compiler can detect these errors, and will output an error message saying what it thinks the error is, and where it thinks the error is

55 Error Messages Run-time error: An error that is not detected until a program is run The compiler cannot detect these errors: an error message is not generated after compilation, but after execution Logic error: A mistake in the underlying algorithm for a program The compiler cannot detect these errors, and no error message is generated after compilation or execution, but the program does not do what it is supposed to do 55


Download ppt "Programming Language Concepts & Its Applications"

Similar presentations


Ads by Google