Computer Programming Objectives Program and Programming Algorithms Programs
Computer Programming
Objectives Program and Programming Algorithms & Programs Software Life Cycle Computer Language Generations Flowchart
Program and Programming
Program and Programming Program: ﻣﺠﻤﻮﻋﺔ ﻣﻦ ﺍﻷﻮﺍﻣﺮ ﺍﻟﻤﻜﺘﻮﺑﺔ ﺑﻠﻐﺔ ﺑﺮﻣﺠﺔ ﻳﻘﻮﻡ ﺍﻟﺤﺎﺳﺐ ﺑﺘﻨﻔﻴﺬﻫﺎ • A set of instruction written in a programming language that a computer can execute so that the machine acts in a predetermined way. • Program solves a problem ﺍﻟﺒﺮﻧﺎﻣﺞ ﻳﺤﻞ ﻣﺸﻜﻠﺔ ﻣﻌﻴﻨﺔ • Before writing a program: – Have a thorough understanding of the problem – Carefully plan an approach for solving it. Programming: ﺍﻟﺒﺮﻣﺠﺔ ﻫﻲ ﻋﻤﻠﻴﺔ ﻛﺘﺎﺑﺔ ﺃﻮﺍﻣﺮ ﻟﻠﺤﺎﺳﺐ ﺗﺨﺒﺮ ﺍﻟﻤﻌﺎﻟﺞ ﺑﻤﺎ ﻳﺠﺐ ﺃﻦ ﻳﻘﻮﻡ ﺑﻪ • The Process of providing instructions to the computer that tells the processor what to do. 4
Algorithms and Programs
Algorithms and Programs ﺍﻟﺨﻮﺍﺭﺯﻣﻲ ﻳﻘﺪﻡ ﺣﻼ ﻟﻤﺸﻜﻠﺔ ﺩﻭﻥ ﺍﻻﻋﺘﻤﺎﺩ ﻋﻠﻰ ﺃﻲ ﻟﻐﺔ ﻟﻠﺒﺮﻣﺠﺔ ﺑﻴﻨﻤﺎ ﺍﻟﺒﺮﻧﺎﻣﺞ ﻋﺒﺎﺭﺓ ﻋﻦ ﺧﻮﺍﺭﺯﻣﻲ ﻣﻜﺘﻮﺏ ﺑﻠﻐﺔ ﻣﻌﻴﻨﺔ An Algorithm is a solution to a problem that is independent of any programming language. While A program is an algorithm expressed using a specific set of instructions from any programming language. 6
Algorithm Example • Maximum of two numbers Steps: 1. Read/input two numbers 2. Compare two numbers 3. Print the Greater number • Average of three numbers Steps: 1. Read/input three numbers 2. Add three numbers 3. divide the sum by 3. 4. Print the result of divison 7
Software Life Cycle
Software Life Cycle What Requirements Gathering, Problem definition Analysis and Design (Programming techniques) How Coding Do it Testing Test Use Implementation and Maintenance 9
Computer Language Generations
Computer Language generations Machine language Assembly languages High-level languages Very high-level languages Natural languages ﻟﻐﺔ ﺍﻵﻠﺔ ﻟﻐﺔ ﺍﻟﺘﺠﻤﻴﻊ ﻟﻐﺔ ﺍﻟﻤﺴﺘﻮﻯ ﺍﻟﻌﺎﻟﻲ ﺟﺪﺍ ﺍﻟﻠﻐﺎﺕ ﺍﻟﻄﺒﻴﻌﻴﺔ 11
Machine Language Programs and memory locations are written in strings of 0 s and 1 s ﺃﺼﻔﺎﺭ ﻭآﺤﺎﺩ Problems with machine languages n n Programs are difficult to write and debug Each computer has its own machine language Only option available to early programmers ﻛﺎﻧﺖ ﺗﺴﺘﺨﺪﻡ ﻓﻲ ﺑﺮﻣﺠﺔ ﺣﺎﺳﺒﺎﺕ ﺍﻟﺠﻴﻞ ﺍﻷﻮﻝ 12
Assembly Languages : ﺗﺴﺘﺨﺪﻡ ﺣﺮﻭﻑ ﺑﺪﻻ ﻣﻦ ﺍﻟﺼﻔﺮ ﻭﺍﻟﻮﺍﺣﺪ ﻣﺜﻞ n n For example, A for add, C for compare, etc. Use names rather than binary addresses for memory locations Require an assembler to translate the program into machine language ﺗﺤﺘﺎﺝ ﻟﺒﺮﻧﺎﻣﺞ ﻳﺴﻤﻲ ﺍﻟﻤﺠﻤﻊ ﻟﻠﺘﺮﺟﻤﺔ Still used for programming chips and writing utility programs ﻣﺎﺯﺍﻟﺖ ﺗﺴﺘﺨﺪﻡ ﻟﺒﺮﻣﺠﺔ ﺍﻟﺸﺮﺍﺋﺢ 13
High-Level Languages Transformed programming n n Programmers could focus on solving problems rather than manipulating hardware Programs could be written and debugged much more quickly Requires a compiler to convert the statements into machine language n Each computer has its own version of a compiler for each language. 14
Very High-Level Languages Also called fourth-generation languages (4 GLs) Considered nonprocedural languages n n The programmer specifies the desired results, and the language develops the solution Programmers can be about 10 times more productive using a fourth-generation language than a third-generation language 15
Natural Languages Resemble written or spoken English n Programs can be written in a natural syntax, rather than in the syntax rules of a programming language The language translates the instructions into code the computer can execute 16
Major Programming Languages FORTRAN COBOL BASIC RPG Visual Basic C Java 17
Object-Oriented Languages C++ Java C# Visual Basic 18
Flowchart
Flowchart ﺧﺮﻳﻄﺔ ﺳﻴﺮ ﺍﻟﻌﻤﻠﻴﺎﺕ – Graphical representation of an algorithm – Components: • Arrows/lines: Flow of control • Parallelogram: Indicates input and output operations • Rectangle symbol (action symbol): Indicates any type of action/computational step • Oval symbol: Indicates the start or the end of a program or a section of code • Diamond: Decision. 20
Flowchart Notations Arrows Diamond Parallelogram Rectangle Oval 21
Example: Add two Numbers START READ A, B Sum = A+B PRINT Sum Stop 22
- Slides: 22