Developing logic (Examples on algorithm and flowchart)

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING TECHNIQUES
1.4 Programming Tools Flowcharts Pseudocode Hierarchy Chart
Flow Control Analysis & Design Tool: Flowcharts
UNIT 2. Introduction to Computer Programming
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS AND FLOWCHARTS
Chapter 1 Pseudocode & Flowcharts
Fundamentals of Algorithms MCS - 2 Lecture # 4
Flow Chart.
King Saud University College of applied studies and community services CSC 206 Programming with Basic Lecture 1.
Chapter 2- Visual Basic Schneider
Chapter 3 - Structured Program Development
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
Structured Program Development in C
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Algorithm & Flowchart.
Fundamentals of C programming
Chapter 1 Pseudocode & Flowcharts
ALGORITHMS AND FLOWCHARTS
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
C++ If….Else Statements and Flowcharts October 10, 2007.
Flowcharts! January 13, 2005 These are today’s notes! Do you think we will get more snow?
End Show Writing a computer program involves performing the following tasks. 1. Understanding the problem 2. Developing an Algorithm for the problem 3.
Software Life Cycle What Requirements Gathering, Problem definition
Algorithm & Flow Charts
PSEUDOCODE C Programming Technique – Firdaus-Harun.com.
C Lecture Notes 1 Structured Program Development.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Chapter 1 Pseudocode & Flowcharts
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 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.
Introduction to Computing Dr. Nadeem A Khan. Lecture 2.
LESSON 1 Introduction to Programming Language. Computer  Comprised of various devices that are referred to as HARDWARE.  The computer programs that.
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.
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
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
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 Solving Flowcharts. Flowcharts Introduction  Flowcharts allow us to create a visual representation of a solution to a problem DRAW  With flowcharts,
Program design Program Design Process has 2 phases:
ALGORITHMS AND FLOWCHARTS
GC101 Introduction to computers and programs
Amalan Kejuruteraan Sem /2014
Unit 3: ALGORITHMS AND FLOWCHARTS
Chapter One Problem Solving
Computer Programming.
Chapter 2- Visual Basic Schneider
ALGORITHMS AND FLOWCHARTS
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
Introduction to Computing
CS111 Computer Programming
Computer Programming Flowchart.
Algorithms and Flowcharts
Numbering System TODAY AND TOMORROW 11th Edition
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
Chapter 2- Visual Basic Schneider
Introduction to Programming
Structural Program Development: If, If-Else
Introduction to Flowcharts
Presentation transcript:

Developing logic (Examples on algorithm and flowchart) CS-101 Lecture 10 Algorithm and Flow Chart Developing logic (Examples on algorithm and flowchart) Department of Computer Science College of Arts and Science 1

Relational Operator Operator Description > Greater than < Smaller than ≤ Smaller than or Equal ≥ Greater than or Equal = Equal ≠ Not Equal 2

If else structure The structure is as follows If condition then true alternative else false alternative endif 3

If else structure is A>B Print B Print A Y N Print A Print B 4

Example (1) Step 1: Start. Step 2: Input M1,M2,M3,M4 Step 3: GRADE  (M1+M2+M3+M4)/4 Step 4: if (GRADE < 60) then Print “FAIL” else Print “PASS” endif 5

Example (2) Write a algorithm to find out number is odd or even? step 1 : start step 2 : input number step 3 : rem=number mod 2 step 4 : if rem=0 then                print "number even"            else                print "number odd"            endif step 5 : stop Mr.Mohammed Rahmath

Chapter 2- Visual Basic Schneider What is a flowchart? Diagram that visually represents the steps that the program performs to arrive at a solution. A popular logic tool used for showing an algorithm in graphical form. Name: Flowlinee: Used to connect symbols and indicate the flow of logic Terminal: Used to represent the beginning or the end of task Input/output: Used for input and output operations, such as reading and printing. Processing: Used for arithmetic and data manipulation operations Decision: Used for any logic or comparison operations. Unlike the two other symbols , which have one entry and one exit flowline, the decision symbol has one entry and two exit paths. Chapter 2- Visual Basic Schneider

Chapter 2- Visual Basic Schneider Continue flowchart Programmer draws flowchart before coding. Most common flowchart symbols are: Flowline: indicates flow of logic. (arrow ) Terminal: represents beginning or end of task (oval ) Input/Output: represents input or output operations (parallelogram ) Processing: data manipulation operations (rectangle ) Decision: used for logic or comparison operation (diamond ) Chapter 2- Visual Basic Schneider

Chapter 2- Visual Basic Schneider Start Example of Flowchart: Initialize counter and sum to 0 Are there more data? No Yes Get next grade This is a program to insert grades and calculate the average Determine the average grade of a class Increment counter Add grade to sum Average=sum/counter Print the average Chapter 2- Visual Basic Schneider Finish

Cont.. PRINT “PASS” START Input M1,M2,M3,M4 GRADE(M1+M2+M3+M4)/4 “FAIL” STOP Y N Print “Pass” Print “Fail” 10

Example (2) Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. Pseudocode Input the width (W) and Length (L) of a rectangle Calculate the area (A) by multiplying L with W Print A 11

Thank you for your attention Lecturer : Aasd Abd Elrashid