CSC 425 Introduction To Computer Programming 1 OBJECTIVES

CSC 425 - Introduction To Computer Programming 1

OBJECTIVES Introduce the general step programmers go through to develop computer programs and software Explain the phases in the system development life cycle. CSC 425 - Introduction To Computer Programming 2

Programming Life Cycle Problem Analysis Programs Modelling Coding Programs Testing and Debugging D o c u me n t a t I o n Maintenance CSC 425 - Introduction To Computer Programming 3

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 CSC 425 - Introduction To Computer Programming Process Output 4

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 numbers Process : 1. total up 3 numbers 2. Divide the number by 3 Output : 3 numbers and the average CSC 425 - Introduction To Computer Programming 5

Step 2 : Programs Modeling Planning the solution to a problem Using algorithm, flowchart or pseudocode [Refer Problem 1] 1. Set sum = 0, avg = 0 2. Read 3 integer number 3. Total up 3 integer number sum = a+b+c 4. Find the average avg = sum / 3 5. Display 3 integer number and average algorithm CSC 425 - Introduction To Computer Programming 6
![[Refer Problem 1] start sum =0 , avg = 0 Read a, b, c [Refer Problem 1] start sum =0 , avg = 0 Read a, b, c](http://slidetodoc.com/presentation_image_h2/5466e929935ec987a47058fb438d3958/image-7.jpg)
[Refer Problem 1] start sum =0 , avg = 0 Read a, b, c sum = a+b+c avg = sum / 3 Display a, b, c Display avg START INPUT a, b, c sum = a+b+c avg = sum / 3 PRINT a, b, c PRINT avg END Pseudocode End Flowchart CSC 425 - Introduction To Computer Programming 7

Step 3 : Coding and programs source code 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) CSC 425 - Introduction To Computer Programming 8
![[Refer problem 1] Coding in C++ Language Output of the program CSC 425 - [Refer problem 1] Coding in C++ Language Output of the program CSC 425 -](http://slidetodoc.com/presentation_image_h2/5466e929935ec987a47058fb438d3958/image-9.jpg)
[Refer problem 1] Coding in C++ Language Output of the program CSC 425 - Introduction To Computer Programming 9

Step 4 : Testing and Debugging Trace error either syntax or logic error Testing running the program with a set of data Debugging Trace and fixed the error CSC 425 - Introduction To Computer Programming 10

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 CSC 425 - Introduction To Computer Programming 11

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 CSC 425 - Introduction To Computer Programming 12

Documentation 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 CSC 425 - Introduction To Computer Programming 13

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 CSC 425 - Introduction To Computer Programming 14

Step 5 : Maintenance Modification made to the finished program Software to meet current requirement Need to refer the previous documentation CSC 425 - Introduction To Computer Programming 15

Accuracy Reliability Efficiency Maintainability A good program must have Readability Usability CSC 425 - Introduction To Computer Programming 16
- Slides: 16