Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lesson - 2. Introduction When we make a program we must follow some steps, called Programming Development Life Cycle (PDLC). Programming steps are five:

Similar presentations


Presentation on theme: "Lesson - 2. Introduction When we make a program we must follow some steps, called Programming Development Life Cycle (PDLC). Programming steps are five:"— Presentation transcript:

1 Lesson - 2

2 Introduction When we make a program we must follow some steps, called Programming Development Life Cycle (PDLC). Programming steps are five: 1. Formulate the Problem 2. Design the Solution 3. Code the Program (Implement the Solution) 4. Test the Program 5. Document and Maintain

3 Example Problem Make a program which asks the constants a, b, c and finds the roots of second degree equation.

4 1. Formulate the Problem What is this program supposed to do? It should finds the roots of second degree equation ax 2 + bx +c =0 What kind of information is it given? (What is the input?) Constants a,b and c are given by keyboard. What kind of results is it to produce? (What is the output?) The output are roots x1 and x2

5 1. Formulate the Problem What formulas or techniques will be needed? Find the Discriminant Δ=b 2 -4ac Find the Roots If Δ > 0 then where If Δ = 0 then where Else there are not real roots. and

6 2. Design the Program Designing the overall structure of the program to solve the problem. Design the Algorithm of program.

7 2. Design the Program The algorithm of our problem will be: 1. Start 2. Read a, b and c constants 3. Calculate the Discriminat Δ=b 2 -4ac 4.If Δ > 0 Then 4.1 Calculate and 4.2 Display x 1 and x 2 4.3Else If Δ = 0 Then 4.3.1 Calculate x1=x2=-b/2*a 4.3.2Display x 1 or x 2 4.3.3 Else Display Message “There aren’t Real Roots” 5. End

8 3. Code the Program After the program has been designed it must be coded or written in a programming language to be translated in a language that computer can understand. Code the program in appropriate programming language following the syntax carefully.

9 3. Code the Program # include using namespace std; int main () { int a,b,c; float d, x1, x2; cout << "Enter the constants a,b and c"<<endl; cin >> a >>b >>c; d=b*b-4*a*c; if (d>0) { x1=(-b+sqrt(d))/2*a; x2=(-b-sqrt(d))/2*a; cout<<"Roots of this equation are: " << x1 <<" and " <<x2 <<endl; } else if (d=0) { x1=-b/2*a; cout<<"Roots of this equation are equal and they are: " << x1 <<endl; } else { cout<<"This equation doesn't have real roots" <<endl; } system("pause"); return 0; }

10 4. Test the Program Compiling is the process of translating the human code (written code) into binary language (machine language). When we compile the code we will check errors. There are two main types of errors: syntax errors logic errors.

11 4. Test the Program Syntax errors are problems with grammar, spelling, or punctuation. If you have left off a semi colon or added one where you shouldn’t have or misspelled a reserve (key) word, these are all syntax errors. These are the easiest ones to find because the program itself helps you to find them.

12 4. Test the Program Logic errors are errors that make a program’s results incorrect. These are much more difficult to find. No compiler will stop and tell you that you have a logic error. The programmer, need to find the logic errors by yourself.

13 5. Document and Maintain To Document is to put together all of the materials that have been generated throughout the PDLC process. All of the flowcharts, messages, algorithms, lines of code, and the user manuals are part of this documentation. There are two types of documentation: Internal documentation External documentation

14 5. Document and Maintain To maintain is to make sure that the program keeps running as it should and to do any needed updating or fixing. Maintenance is the longest phase of the PDLC. As users use the program, they will notice things that need to be fixed or updated.

15 Thank you!


Download ppt "Lesson - 2. Introduction When we make a program we must follow some steps, called Programming Development Life Cycle (PDLC). Programming steps are five:"

Similar presentations


Ads by Google