0% found this document useful (0 votes)
7 views

Programming Lecture 1

The document outlines the programming process and the program development life cycle, which includes problem analysis, algorithm implementation, and maintenance. It discusses the evolution of programming languages from machine language to high-level languages and the role of compilers in translating code. Additionally, it provides examples of simple programming tasks, such as calculating the area and perimeter of geometric shapes.

Uploaded by

Ahmed Samy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Programming Lecture 1

The document outlines the programming process and the program development life cycle, which includes problem analysis, algorithm implementation, and maintenance. It discusses the evolution of programming languages from machine language to high-level languages and the role of compilers in translating code. Additionally, it provides examples of simple programming tasks, such as calculating the area and perimeter of geometric shapes.

Uploaded by

Ahmed Samy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Under the supervision of

Dr. Ghofran Mohamad


What Is Programming and Program Development Life
Cycle ?

• Programming is a process of problem solving

• Step 1: Analyze the problem


– Outline the problem and its requirements
– Design steps (algorithm) to solve the problem

• Step 2: Implement the algorithm


– Implement the algorithm in code
– Verify that the algorithm works

• Step 3: Maintenance
– Use and modify the program if the problem domain changes

Algorithm:
– Step-by-step problem-solving process

2
The Problem Analysis–Coding–Execution Cycle

• Understand the Overall problem

• Understand problem requirements


– Does program require user interaction?
– Does program manipulate data?
– What is the output?

• If the problem is complex, divide it into subproblems


– Analyze each subproblem as above

3
The Problem Analysis–Coding–Execution
Cycle (cont'd.)
• Run code through compiler

• If compiler generates errors


– Look at code and remove errors
– Run code again through compiler

• If there are no syntax errors


– Compiler generates equivalent machine code

• Linker links machine code with system resources

4
The Problem Analysis–Coding–Execution
Cycle (cont'd.)
• Once compiled and linked, loader can place program into main memory
for execution

• The final step is to execute the program

• Compiler guarantees that the program follows the rules of the language
– Does not guarantee that the program will run correctly

C++ Programming: From Problem Analysis to Program


5 Design, Fifth Edition
The Language of a Computer

• Machine language: language of a computer

• Binary digit (bit):


– The digit 0 or 1

• Binary code:
– A sequence of 0s and 1s

• Byte:
– A sequence of eight bits

6
The Evolution of Programming Languages

• Early computers were programmed in machine language

• To calculate wages = rates * hours in machine language:


100100 010001 //Load
100110 010010 //Multiply
100010 010011 //Store

C++ Programming: From Problem Analysis to Program


7 Design, Fifth Edition
The Evolution of Programming Languages
• Assembly language instructions are mnemonic

• Assembler: translates a program written in assembly language into


machine language

C++ Programming: From Problem Analysis to Program


8 Design, Fifth Edition
The Evolution of Programming Languages
• Using assembly language instructions, wages = rates • hours can
be written as:

LOAD rate
MULT hour
STOR wages

9
The Evolution of Programming Languages

• High-level languages include Basic, FORTRAN, COBOL, Pascal, C, C++,


C#, and Java

• Compiler: translates a program written in a high-level language machine


language

• The equation wages = rate • hours can be written in C++ as:


wages = rate * hours;

10
The Problem Analysis–Coding–Execution Cycle
Problem Analysis

Using Any Algorithm Design


Programming
Language

Coding

Complier
Translate Code Errors
To Machine
Language
Execution
Errors

Get Results

11
Then
Think Write Code

12
Basic Definitions

• Programming language:
– a set of rules, symbols, and special words used to write computer
programs.

• Computer program
– Sequence of statements whose objective is to accomplish a task.

• Syntax:
– rules that specify which statements (instructions) are legal

13
Computer System

Oper
2

Oper

Input 2
Operation
Output
1

Processing

14
Example 1
• Write a program to find the Area of a rectangle

The area of the Rectangle are given by the following formula:

Area = Rect Length * Rect Width.

Input :
Rectangle Length , Rectangle Width.

Processing :
Area = Rect Length * Rect Width.

Output :
Print Out The area.

15
Example 2
• Write a program to find the perimeter and area of a square

The perimeter and area of the square are given by the following formulas:
perimeter = Side Length * 4
area = Side Length * Side Length
Input:
Square Side Length
Processing:
perimeter = Side Length * 4
area = Side Length * Side Length
Output:
Print Out The Perimeter and Area.

16
17
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 18
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 19
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 20
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 21
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 22
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 23
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 24
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 25
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 26
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 27
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 28
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 29
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 30
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 31

You might also like