Computer Programming
Objectives Program and Programming Algorithms & Programs Software Life Cycle Computer Language Generations Flowchart
Program and Programming
Program and Programming 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.
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.
Algorithm Example Maximum of two numbers Steps: Read/input two numbers Compare two numbers Print the Greater number Average of three numbers Read/input three numbers Add three numbers divide the sum by 3. Print the result of divison
Software Life Cycle
Software Life Cycle What Requirements Gathering, Problem definition How Analysis and Design (Programming techniques) Do it Coding Test Testing Use Implementation and Maintenance
Computer Language Generations
Computer Language generations Machine language لغة الآلة Assembly languages لغة التجميع High-level languages لغة المستوى العالي Very high-level languages لغة المستوى العالي جدا Natural languages اللغات الطبيعية
Machine Language Programs and memory locations are written in strings of 0s and 1sأصفار وآحاد Problems with machine languages Programs are difficult to write and debug Each computer has its own machine language Only option available to early programmersكانت تستخدم في برمجة حاسبات الجيل الأول
Assembly Languages تستخدم حروف بدلا من الصفر والواحد مثل: 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 مازالت تستخدم لبرمجة الشرائح
High-Level Languages Transformed programming 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 Each computer has its own version of a compiler for each language.
Very High-Level Languages Also called fourth-generation languages (4GLs) Considered nonprocedural languages 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
Natural Languages Resemble written or spoken English 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
Major Programming Languages FORTRAN COBOL BASIC RPG Visual Basic C Java
Object-Oriented Languages Java C# Visual Basic
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.
Flowchart Notations Arrows Diamond Parallelogram Oval Rectangle
Example: Add two Numbers START READ A,B Sum = A+B PRINT Sum Stop