1 Program Planning and Design Important stages before actual program is written.

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING TECHNIQUES
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS AND FLOWCHARTS
Chapter 2 - Problem Solving
Fundamentals of Algorithms MCS - 2 Lecture # 4
Chapter 2- Visual Basic Schneider
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 3 Planning Your Solution
BPC.1 Basic Programming Concepts
Review Algorithm Analysis Problem Solving Space Complexity
PRE-PROGRAMMING PHASE
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
Fundamentals of C programming
ALGORITHMS AND FLOWCHARTS
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Programming Lifecycle
CHAPTER 2 PART #3 INPUT - OUTPUT 1 st semester King Saud University College of Applied studies and Community Service Csc
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Chapter 2: General Problem Solving Concepts
1 Programming Tools Flowcharts Pseudocode Hierarchy Chart Direction of Numbered NYC Streets Algorithm Class Average Algorithm.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
The Hashemite University Computer Engineering Department
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Lecture 3 Computer Programming -1-. The main steps of program development to solve the problem: 1- problem definition : The problem must be defined into.
 Problem Analysis  Coding  Debugging  Testing.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
GC101 Introduction to computers and programs
Programming Languages
Unit 3: ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
ALGORITHMS AND FLOWCHARTS
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
CS111 Computer Programming
Algorithms and Flowcharts
Algorithms An algorithm is a sequence of steps written in the form of English phrases that specific the tasks that are performed while solving the problem.It.
Lecture 2 Introduction to Programming
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Algorithm and Ambiguity
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
Problem Solving Techniques
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Introduction to Algorithms and Programming
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Programming Fundamentals (750113) Ch1. Problem Solving
Flowcharts and Pseudo Code
ICT Gaming Lesson 2.
Introduction to Programming
Programming Fundamentals (750113) Ch1. Problem Solving
Basic Concepts of Algorithm
CHAPTER 6 Testing and Debugging.
Presentation transcript:

1 Program Planning and Design Important stages before actual program is written

2 Steps to Problem-solving Analyze the problem and develop specifications Analyze the problem and develop specifications Design solutions Design solutions Code the program with documentation Code the program with documentation Test the program Test the program Validate the program Validate the program

3 Algorithm Definition 1: The sequence of steps required to solve a problem Definition 1: The sequence of steps required to solve a problem Definition 2: A definite list of well-defined instructions for completing a task; that given an initial state, will proceed through a well-defined series of successive states, eventually terminating in an end-state. Definition 2: A definite list of well-defined instructions for completing a task; that given an initial state, will proceed through a well-defined series of successive states, eventually terminating in an end-state.

4 Presentation of Algorithms Structure Chart: Structure Chart: Structure of modules needed to solve a problem. Structure of modules needed to solve a problem. Pseudo-codes: Pseudo-codes: Semiformal, English-like list of steps of the algorithm. Semiformal, English-like list of steps of the algorithm. Flow-charts: Flow-charts: Graphical/schematic representation of an algorithm. Graphical/schematic representation of an algorithm.

5 Structure Chart To chart out the modules and statements to break down a programming problem To chart out the modules and statements to break down a programming problem Multiply two integers Get two integers Formula Print result no1no2 Multiply= no1 * no2 Multiply

6 Pseudo-code Semi-formal, English-like description of logic of the algorithm Semi-formal, English-like description of logic of the algorithm Helps programmer to “think out” the program Helps programmer to “think out” the program Advantage: Advantage: Simple Simple Easy to understand Easy to understand

7 Example of Pseudo-code: To calculate Sales Amount: 1. First get user to enter quantity 2. Get the price of the product 3. Calculate amount = price * quantity 4. Display the amount

8 Example of Pseudo-code: Write an algorithm of a program that will accept four marks and determine a student’s final grade and indicate whether it is passing or failing. The passing mark is 50. The final grade is calculated as the average of four marks. Write an algorithm of a program that will accept four marks and determine a student’s final grade and indicate whether it is passing or failing. The passing mark is 50. The final grade is calculated as the average of four marks. Pseudo-code: Input a set of 4 marks Input a set of 4 marks Calculate their average by summing and dividing by 4 Calculate their average by summing and dividing by 4 If average is below 50 If average is below 50 Print “FAIL” else Print “PASS”

9 Flow-Charts Graphical representation of an algorithm Graphical representation of an algorithm Uses symbols and shapes to describe flow or process of the algorithm to solve a problem. Uses symbols and shapes to describe flow or process of the algorithm to solve a problem. Example: Example:

10 Flow-charting Symbols Selection/ Decisions ProcessConnectors Input/Output Terminators Direction of Flow Loop

11 Flow-charting Symbols (continued)

12 Example of Flowchart: START Input M1, M2, M3, M4 GRADE  (M1+M2+M3+M4)/4 IS GRADE<5 0 STOP YESNO Print PASSPrint FAIL Pseudo-code: Input a set of 4 marks Input a set of 4 marks Calculate their average by summing and dividing by 4 Calculate their average by summing and dividing by 4 If average is below 50 If average is below 50 Print “FAIL” else Print “PASS”

13 Example of Flowchart (continued) :

14 Debugging A process to remove error A process to remove error Error = bug, the first computer “bug” is a bug found on a printer Error = bug, the first computer “bug” is a bug found on a printer 4 kinds of errors : 4 kinds of errors : Syntax error Syntax error Run-time error Run-time error Undetected error Undetected error Logic/semantic error Logic/semantic error

15 1. Syntax error Violation of the C grammar rules, detected during program translation (compilation) Violation of the C grammar rules, detected during program translation (compilation) Example: Example: Missing semicolon Missing semicolon Undeclared variable Undeclared variable

16 2. Run-Time Errors An attempt to perform an invalid operation detected during program execution An attempt to perform an invalid operation detected during program execution Example: Example: Dividing a number by zero Dividing a number by zero When a run time occurs, the computer will stop executing your program and will display a diagnostic message that indicates the line where an error was detected When a run time occurs, the computer will stop executing your program and will display a diagnostic message that indicates the line where an error was detected

17 3. Undetected errors Many execution error may not prevent a C programming from running to completion but they may simply lead to incorrect result Many execution error may not prevent a C programming from running to completion but they may simply lead to incorrect result Example: Example: When programmer forgot to write ‘&’ in scanf When programmer forgot to write ‘&’ in scanf The program runs to completion using whatever “garbage” value originally in the memory locations named to variable in scanf The program runs to completion using whatever “garbage” value originally in the memory locations named to variable in scanf

18 4. Logic Errors An error caused by following an incorrect algorithm An error caused by following an incorrect algorithm Usually do not cause run-time errors and do not display error messages, they are difficult to detect Usually do not cause run-time errors and do not display error messages, they are difficult to detect