Docsity

Program Development Cycle-Programming-Lecture Slides, Slides of Computer Programming

Partial preview of the text

Download Program Development Cycle-Programming-Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

2

Program Development Cycle:1. Analyze: Define the problem2. Design: Plan the solution to theproblem. Do it on paper.

3

Program

Development Cycle:

3. Code: Translate the algorithm into aprogramming language.4. Debug and Test: Locate and removeany errors in the program.5. Complete the Documentation: Organizeall the materials that describe theprogram. Document all stages ofdevelopment.

5

What is a flowchart?^ Logic diagram to describe each stepthat the program must perform toarrive at the solution.^ A popular logic tool used for showing analgorithm in graphics form.

6

Purpose of Flowcharting:^ An aid in developing the logic of aprogram.^ Verification that all possible conditionshave been considered in a program.^ Provides means of communication withothers about the program.^ A guide in coding the program.^ Documentation for the program.

8

FlowchartsDecision: Logic comparison operations.Have one entry and two exit points

Question?

Yes No

9

FlowchartsStart and Stop Points

11

FlowchartsFlow lines: Show the flow of controlthrough the flow chart between theprocesses and decision boxes.

12

Advantages andDisadvantages of Flowcharts^ For^ 

Easy to create  Easy to read Against  Very procedure oriented (i.e. Not ObjectOriented!)

14

‘for’ Loopfor(initialisation;

condition;update)

{ … statements to do;… }^

Is Conditiontrue?

No

Update Do theseinstructionsYes Initialisation

Init, update, conditionDo theseinstructions

15

‘do…while(

Condition)’ Loop

do { … statements to do;… } while(

condition);

Is Conditiontrue?

No Do theseinstructions

Yes

17

Summation Solution

Start Stop

i = i + 1 No

Yes sum=0i = 0 Is i <= N

sum=sum+i

InputN Outputsum

18

Factorial Exercise^ Write the flow diagram for the casewhere a positive number N is input, andthe factorial of N is calculated andoutput to the screen.Factorial of N = N! = N(N-1)(N-2)…1So Factorial of 5 = 5! = 54321 = 120.

20

Reverse Engineering^ Take C code and turn it into a flow chart. #include<stdio.h>int main(){ int i=0;while(i<10){ printf(“%d\n”,i);;i = i+1;} return (0);}

Start i = 0 Is i < 10 Stop

i = i + 1 Yes No Outputi

21

Reverse Engineering Exercise Take code C and turn it into a flow chart. #include<stdio.h>int main(){ int i,n,sum;printf("Enter a positive integer\n“);scanf(“%d”, &n);sum=0;for(i=0; i<(n+1); i++){ if(i%2==0) continue;sum =sum + i;} printf("The sum of %d first even integers = %d\n”, n, sum);return (0);}