Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 4: ALGORITHM 4.1 Introduction stages identified in the program development process: 1. Problem analysis and specification 2. Data organization.

Similar presentations


Presentation on theme: "CHAPTER 4: ALGORITHM 4.1 Introduction stages identified in the program development process: 1. Problem analysis and specification 2. Data organization."— Presentation transcript:

1 CHAPTER 4: ALGORITHM 4.1 Introduction stages identified in the program development process: 1. Problem analysis and specification 2. Data organization and algorithm design A plan with two parts to solve a problem: I. Determine how to organize and store the data. II. Develop procedures to process data and produce output. These procedures are called algorithms 3. Program coding The process of implementing data objects and algorithms in some programming language 4.Execution and testing Check that the algorithm and program are correct. 5. Program maintenance

2 4.2 Algorithm A sequence of logical steps for solving a problem. Algorithm methods: Pseudocode: Algorithm steps in a series of English-like statements. It uses a mixture of natural language and symbols, terms, and other features Flowchart: graphical representation of algorithm steps. (see Table 3.1). Structured algorithms and programs are designed using three basic methods of control: sequential, selection, and repetition.

3 1. Sequential Method: Steps are performed in a strictly sequential manner, each step being executed once. Example: Develop a computer algorithm that computes the area of a circle for a given radius.

4 Fortran Program program Area_of_a_circle Read *,r area=3.14*r**2 print*,R, area stop end program Area_of_a_circle START READ R A=  R 2 PRINT R,A STOP

5 2. Selection Method One of a number of alternative action is selected and executed. Example: Write an algorithm for computing the zakat of the total annual saving of a person. START READ TAS,A TAS<A Z=0.025TAZ Z=0 PRINT TAZ,Z STOP YESNO

6 3. Repetition Method One or more steps are performed repeatedly. Example: Write an algorithm (flow chart) for computing and printing the summation of the squares of integer numbers between 2 and 50. S =  N 2 START S=0, N=2 S=S+N 2 N=N+1 N  50 PRINT S STOP YES NO

7 EXAMPLES 1.Write an algorithm for computing and printing the arithmetic and engineering means for three variables, x, y, and z. Then write the Fortran program and execute it. Arithmetic Mean=(x+y+z)/3 Engineering Mean =(x+y+z) (1/3)

8


Download ppt "CHAPTER 4: ALGORITHM 4.1 Introduction stages identified in the program development process: 1. Problem analysis and specification 2. Data organization."

Similar presentations


Ads by Google