Program design Program Design Process has 2 phases:

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

PROBLEM SOLVING TECHNIQUES
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS AND FLOWCHARTS
Chapter 2 - Problem Solving
 Control structures  Algorithm & flowchart  If statements  While statements.
Chapter 2- Visual Basic Schneider
Developing logic (Examples on algorithm and flowchart)
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Fundamentals of C programming
Chapter 1 Pseudocode & Flowcharts
ALGORITHMS AND FLOWCHARTS
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
©Brooks/Cole, 2003 Chapter 8 Algorithms. ©Brooks/Cole, 2003 Understand the concept of an algorithm. Define and use the three constructs for developing.
Structured Program Development Outline 2.1Introduction 2.2Algorithms 2.3Pseudo code 2.4Control Structures 2.5The If Selection Structure 2.6The If/Else.
Software Life Cycle What Requirements Gathering, Problem definition
Algorithm & Flow Charts
Lecture 2: Logical Problems with Choices. Problem Solving Before writing a program Have a thorough understanding of the problem Carefully plan an approach.
PSEUDOCODE C Programming Technique – Firdaus-Harun.com.
C Lecture Notes 1 Structured Program Development.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Chapter 2: General Problem Solving Concepts
Basic Control Structures
Flowcharting & Algorithms. Quick. Close your Eyes and Listen You are still sitting in the classroom. However, you have been called to the counselor’s.
1 Program Planning and Design Important stages before actual program is written.
Chapter 8 Algorithms.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Concepts of Algorithms CSC-244 Unit Zero Pseudo code, Flowchart and Algorithm Master Prince Computer College Qassim University K.S.A.
Problem, Problem Solving, Algorithm & Flow Charts –Part 1 Presented By Manesh T Course:101 CS 101CS Manesh T1.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
©Brooks/Cole, 2003 Chapter 8 Algorithms. ©Brooks/Cole, 2003 CONCEPTCONCEPT 8.1.
Examples of Flow Charts Pseudocodes
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.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
Introduction to Flowcharts
Program Program is a collection of instructions that will perform some task.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Let’s Play Tes Kelemotan Otak.
Lecture 2: Introduction to Programming EEE2108: 공학프로그래밍 서강대학교 전자공학과 2011 학년도 2 학기 - Algorithms and Flowcharts -
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
 Problem Analysis  Coding  Debugging  Testing.
Problem Solving & Computer Programming
ALGORITHMS AND FLOWCHARTS
Algorithm: procedure in terms of
GC101 Introduction to computers and programs
Algorithm & Flow Charts Week 1
Problem Solving Concepts
Unit 3: ALGORITHMS AND FLOWCHARTS
Problem , Problem Solving, Algorithm & Flow Charts –Part 1
Algorithm & Programming
ALGORITHMS AND FLOWCHARTS
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
CS111 Computer Programming
Algorithms and Flowcharts
Programming Fundamentals
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
ALGORITHMS AND FLOWCHARTS
Structured Program
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Introduction to Algorithms and Programming
Computer Science Core Concepts
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
Introduction to Programming
Teori Bahasa dan Automata Lecture 13: Algorithm
REPETITION Why Repetition?
Presentation transcript:

Program design Program Design Process has 2 phases: Problem Solving Phase Creates an algorithm that solves the problem Implementation (Coding) Phase Translates the algorithm into a programming language Problem Program Algorithm

Algorithms An algorithm is a finite set of steps defining the solution of a particular problem. Need not to belong one particular language Sequence of English statements can also be algorithm It is not a computer program An algorithm can be expressed in English like language,called pseudocode, in a programming language or in the form of flowchart. Dr. Vipin Tyagi

Write an algorithm that finds the average of two numbers Solution: Example 1 Write an algorithm that finds the average of two numbers Solution: AverageOfTwo Input: Two numbers Add the two numbers Divide the result by 2 Return the result by step 2 2 End

Write an algorithm to change a numeric grade to a pass/fail grade. Example 2 Write an algorithm to change a numeric grade to a pass/fail grade. Solution: Pass/FailGrade Input: One number if (the number is greater than or equal to 40) then 1.1 Set the grade to “pass” else 1.2 Set the grade to “fail” End if Return the grade End

Example 5 Write an algorithm to find the largest of 1000 numbers. Solution FindLargest Input: 1000 positive integers Set Largest to 0 Set Counter to 0 while (Counter less than 1000) 3.1 if (the integer is greater than Largest) then 3.1.1 Set Largest to the value of the integer End if 3.2 Increment Counter End while Return Largest End

Flowchart A graphical representation of an algorithm, often used in the design phase of programming to work out the logical flow of a program. Visual way to represent the information flow Make our logic more clear Help during writing of program Make testing and debugging easy

Flowchart or program constructs Sequence: The order of execution, this typically refers to the order in which the code will execute. Normally code executes line by line, so line 1 then 2 then 3 and so on.  Selection: Selection, like branching, is a method of controlling the execution sequence, you can create large control blocks, using if statements testing a condition, or switch statements evaluating a variable etc to control and change the execution of the program depending on this environment and changing variables.  Iteration (Repetition): Iteration is typically used to refer to collections and arrays of variables and data. Repeating set of instruction. Counting from 1 to 10, you are iterating over the first 10 numbers. for, while, do-while loops will be implemented for iteration.

Flowchart Constructs

Flowchart Constructs (cont..)

Flowchart Constructs (cont..)

Example-1 Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. Algorithm Step 1: Take Width and Length as input Step 2: Calculate Area by Width* Length Step 3: Print Area.

Example 3 Write an algorithm and draw a flowchart to convert the length in feet to centimeter. Algorithm: Input the length in feet (Lft) Calculate the length in cm (Lcm) by multiplying LFT with 30 Print length in cm (LCM)

Example 3 Pseudocode Step 1: Input Lft Step 2: Lcm  Lft x 30 Step 3: Print Lcm Flowchart START Input Lft Lcm  Lft x 30 Print Lcm STOP

Example 4 Write an algorithm and draw a flowchart that will calculate the roots of a quadratic equation Hint: d = sqrt ( ), and the roots are: x1 = (–b + d)/2a and x2 = (–b – d)/2a

Example 4 Input the coefficients (a, b, c) of the quadratic equation Algorithm: Input the coefficients (a, b, c) of the quadratic equation Calculate d Calculate x1 Calculate x2 Print x1 and x2

Example 4 Pseudocode: Step 1: Input a, b, c Step 2: d  sqrt ( ) START Input a, b, c d  sqrt(b x b – 4 x a x c) Print x1 ,x2 STOP x1 (–b + d) / (2 x a) X2  (–b – d) / (2 x a) Pseudocode: Step 1: Input a, b, c Step 2: d  sqrt ( ) Step 3: x1  (–b + d) / (2 x a) Step 4: x2  (–b – d) / (2 x a) Step 5: Print x1, x2

Example 5 Write an algorithm that reads three numbers and prints the value of the largest number.

Flow Charts Limitation For very large program, flow chart goes for many pages Costly to draw flow charts for large program Difficult to modify