Download presentation
Presentation is loading. Please wait.
Published byΦιλομήνα Ουρανία Κολιάτσος Modified over 5 years ago
1
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
PROBLEM SOLVING PHASES
2
CONTENT Program development life cycle.
Use IPO chart, Algorithm, Pseudocode, and flowchart.
3
Program Development Life Cycle (PLDC)
This methodology consist of steps programmers use to build computer programs.
4
PDLC Analysis Design Implementation Testing and debugging Maintenance
5
STEP 1: ANALYSIS The purpose: to describe in detail a solution to a problem and information needed in solving the problem. How?? Study and understand the problem Identify: Specify the input Specify the output Specify the process ( formulas)
6
To bake a cake…. INPUT
7
To bake a cake….(cont.) PROCESS
8
To bake a cake….(cont.) OUTPUT
9
PROBLEM: To calculate and display age
10
STEP 1: ANALYSIS IPO Chart Input Process Output yearBorn
Age = currentYear - yearBorn Age
11
STEP 2: DESIGN Definition: it is a framework or flow that shows the step in problem solving. Method to use: Algorithm Pseudocode flowchart
12
ALGORITHM A sequence of instruction to solve a problem, written in human language. Get/input the year born Calculate the age using the formula age = current year – year born Print/ display the age
13
PSEUDOCODE Steps in problem solving that is written in half programming code and half in human language. For example, some part uses C++ language code and some part uses English language Begin Read the year born from the user. Age = currentYear - yearBorn Print the user age. End
14
FLOWCHART A representation of graphical symbols to show process or steps in problem solving.
15
Symbols Descriptions Terminal symbol - indicates the beginning and end points of an algorithm. Input-output symbol - shows an input or an output operation. Process symbol - shows an instruction other than input, output or selection. Decision symbol - shows a selection process for two-way selection. On-page connector - provides continuation of logical path at another point in the same page. Flow lines - indicate the logical sequence of execution steps in the algorithm
16
Flowchart Start Input year born Age = current year – year born
Print age End
17
STEP 3: IMPLEMENTATION The process of writing the code that translate the design into a computer program using a programming language. Different languages have different syntax. A language syntax’s is the set of grammar and rules that specifies how to write instructions for an algorithm.
18
Coding # include <iostream.h> void main() { int yearBorn;
int age; int curYear ; cout<< “please enter the current year:”; cin>>curYear; cout<<“please enter year born: ”; cin>>yearBorn; age = curYear – yearBorn; cout<<“Your age is:”<<age; }
19
STEP 4: TESTING The process of running the program and checking for errors. This is to ensure that the programs works like it supposed to. Types of errors: Syntax error Caused by incorrectness in syntax, spelling, undeclared or undefined variables. Run – time error Error that occurs while program is executed with statement that requires the compiler to do something illegal, e.g. division with zero. Logic error Errors in logic or meaning. Output may be produced but not the right one.
20
STEP 4: TESTING Debugging
Process of locating and correcting errors in a program.
21
EDIT – COMPILE – DEBUG - LOOP
Begin Edit program Compile program Compiler errors? Test program Run-time errors? End True False True False
22
STEP 5: MAINTENANCE Any activity that is designed to keep the program in working condition – modification, repairs, enhancement, replacements … Documenting the program – useful incase of modification or maintenance. User manual
23
Exercise: Problem 1 Write a program that will get two numbers from user. Find the summation and the display the result.
24
Exercise: Problem 2 Write a program that will get two numbers from user. Find the average and the display the result.
25
Exercise: Problem 3 To calculate the total of students in a school if the total of boy student are 501 and the total of the girl student is 700.
26
Extra exercises
27
Exercise 1 Assume that you have to write a program to calculate area of a circle using the formula given: area = radius * radius * 3.142 a) define the input, process and output b) draw the flowchart c) write the pseudocode
28
Exercise 2 Write a pseudocode and a flowchart for converting temperature from Fahrenheit to Celsius. User need to input the Fahrenheit. The formula is as follow: celsius = 5.0/9.0 * (Fahrenheit – 32.0)
29
Exercise 3 Assume that you have to write a program to calculate the area of rectangle. Determines the input, output, process. Draw the flowchart Write the pseudocode
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.