16
CSC425 - Introduction To Computer Programming 1

CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

Embed Size (px)

Citation preview

Page 1: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 1

Page 2: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 2

Introduce the general step programmers go through to develop computer programs and software

Explain the phases in the system development life cycle.

OBJECTIVES

Page 3: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 3

Problem Analysis

Programs Modelling

Coding Programs

Testing and Debugging

Maintenance

DocumentatIon

Programming Life CycleProgramming Life Cycle

Page 4: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 4

Step 1 : Problem Analysis

Defining the problem

Identify :

1. Input (given data)

2. Output (the result)

3. Process

- relation between input

and output

- using formula

Input Process Output

Page 5: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 5

Example

Problem 1

Write a program that can input 3 integer number from user. Find the average for the number. Display all the numbers and the average

Problem analysis

Input : 3 numbersProcess : 1. total up 3 numbers

2. Divide the number by 3Output : 3 numbers and the average

Page 6: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 6

Planning the solution to a problem Using algorithm, flowchart or pseudocode

[Refer Problem 1]

1. Set sum = 0, avg = 02. Read 3 integer number3. Total up 3 integer number

sum = a+b+c4. Find the average

avg = sum / 35. Display 3 integer number and average

algorithm

Step 2 : Programs Modeling

Page 7: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 7

[Refer Problem 1]

Flowchart

start

sum =0 , avg = 0

Read a, b, c

sum = a+b+c

avg = sum / 3

Display a,b,cDisplay avg

End

Pseudocode

START INPUT a,b,c sum = a+b+c avg = sum / 3 PRINT a,b,c PRINT avgEND

Page 8: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 8

Express solution in a programming language Translate the logic from the flowchart or

pseudocode. There are many programming languages : BASIC,

COBOL, Pascal, Fortran, C, C++, Java etc Each language has it’s own syntax (rules of

language)

Step 3 : Coding and programs

source code

Page 9: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 9

[Refer problem 1]

Coding in C++ Language

Output of the program

Page 10: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 10

Trace error either syntax or logic error

Testing running the program with a set of data

Debugging Trace and fixed the error

Step 4 : Testing and Debugging

Page 11: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 11

Run-time error

•Occur during program execution•Detected by compiler•Occur because of logic error or memory leak

Syntax error

•Error in the structure or spelling of a statement•Detected by the compiler during compilation of the program•Example:

• Missing semicolon, quote

Page 12: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 12

Logic error

•Unexpected/unintentional errors resulted from flaw in the program’s logic•Produce undesired result/output•Cannot be detected by compiler•Compare the result with manual process

Page 13: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 13

An ongoing process

Written detailed description of the program cycle

and specific facts about the program

Documentation materials include :

1. Description of the program

2. Logic tools : flowcharts, pseudocode

3. Data- record descriptions

4. Program listing

5. Testing results

6. Comments

Documentation

Page 14: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 14

Why programmers put comment?• To explain/describe the

program/function/statement• To help other programmers understand the

program/function/statement• 2 types of comments

• Line comment: single line comment• Block comment: multiple line comment

• Syntax comment is differ to certain languages

Page 15: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 15

Modification made to the finished program

Software to meet current requirement

Need to refer the previous documentation

Step 5 : Maintenance

Page 16: CSC425 - Introduction To Computer Programming 1. 2 Introduce the general step programmers go through to develop computer programs and software Explain

CSC425 - Introduction To Computer Programming 16

A good program

must have

AccuracyAccuracy

ReliabilityReliability

EfficiencyEfficiency

MaintainabilityMaintainability

ReadabilityReadability

UsabilityUsability