Programming Lecture 1
Programming Lecture 1
• 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
3
The Problem Analysis–Coding–Execution
Cycle (cont'd.)
• Run code through compiler
4
The Problem Analysis–Coding–Execution
Cycle (cont'd.)
• Once compiled and linked, loader can place program into main memory
for execution
• Compiler guarantees that the program follows the rules of the language
– Does not guarantee that the program will run correctly
• Binary code:
– A sequence of 0s and 1s
• Byte:
– A sequence of eight bits
6
The Evolution of Programming Languages
LOAD rate
MULT hour
STOR wages
9
The Evolution of Programming Languages
10
The Problem Analysis–Coding–Execution Cycle
Problem Analysis
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
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