ChE-1800 H-2: Flowchart Diagrams (last updated January 13, 2013)



Similar documents
Circumference of a Circle

2 SYSTEM DESCRIPTION TECHNIQUES

HSC Mathematics - Extension 1. Workshop E4

MATLAB Programming. Problem 1: Sequential

Advanced Programming with LEGO NXT MindStorms

2-1 Position, Displacement, and Distance

Chapter 13: Program Development and Programming Languages

Experiment 9. The Pendulum

State Newton's second law of motion for a particle, defining carefully each term used.

Decimals are absolutely amazing We have only 10 symbols, yet can represent any number, large or small We use zero (0) as a place holder to allow us

Adding and Subtracting Positive and Negative Numbers

Student Outcomes. Lesson Notes. Classwork. Exercises 1 3 (4 minutes)

Chapter 19 Magnetic Forces and Fields

Introduction to Matlab

Planetary Orbit Simulator Student Guide

Dr. Lisa White

AMATH 352 Lecture 3 MATLAB Tutorial Starting MATLAB Entering Variables

MECHANICAL PRINCIPLES OUTCOME 4 MECHANICAL POWER TRANSMISSION TUTORIAL 1 SIMPLE MACHINES

6. LECTURE 6. Objectives

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

Lecture 2 Notes: Flow of Control

Universal Law of Gravitation

Sources: On the Web: Slides will be available on:

Difference between a vector and a scalar quantity. N or 90 o. S or 270 o

MATH REVIEW SHEETS BEGINNING ALGEBRA MATH 60

Formulas, Functions and Charts

Introduction to Measurement Tools

Kids College Computer Game Programming Exploring Small Basic and Procedural Programming

Team Name / (Students): Solar Racing (Student Handout) (The Design, Construction, and Evaluation of a Solar-Powered Car)

Circumference and Area of a Circle

AP Physics Circular Motion Practice Test B,B,B,A,D,D,C,B,D,B,E,E,E, m/s, 0.4 N, 1.5 m, 6.3m/s, m/s, 22.9 m/s

Notes for EER #4 Graph transformations (vertical & horizontal shifts, vertical stretching & compression, and reflections) of basic functions.

MATH 60 NOTEBOOK CERTIFICATIONS

Unit 1 Number Sense. In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions.

Physics 121 Sample Common Exam 3 NOTE: ANSWERS ARE ON PAGE 6. Instructions: 1. In the formula F = qvxb:

Accentuate the Negative: Homework Examples from ACE

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Circles: Circumference and Area Lesson Plans

Algorithm and Flowchart Structured Programming 1

Perimeter is the length of the boundary of a two dimensional figure.

Chapter 3 Problem Solving

Ground Rules. PC1221 Fundamentals of Physics I. Kinematics. Position. Lectures 3 and 4 Motion in One Dimension. Dr Tay Seng Chuan

Chapter 3.8 & 6 Solutions

PRACTICE FINAL. Problem 1. Find the dimensions of the isosceles triangle with largest area that can be inscribed in a circle of radius 10cm.

All I Ever Wanted to Know About Circles

Chapter One Introduction to Programming

GAP CLOSING. 2D Measurement. Intermediate / Senior Student Book

MATLAB Workshop 3 - Vectors in MATLAB

Chapter 2: Algorithm Discovery and Design. Invitation to Computer Science, C++ Version, Third Edition

Experiment 2 Free Fall and Projectile Motion

AP Physics B 2008 Scoring Guidelines

Figure 1.1 Vector A and Vector F

Show that when a circle is inscribed inside a square the diameter of the circle is the same length as the side of the square.

KIN Biomechanics LAB: Ground Reaction Forces - Linear Kinetics

Useful Mathematical Symbols

Advanced GMAT Math Questions

E/M Experiment: Electrons in a Magnetic Field.

*X100/12/02* X100/12/02. MATHEMATICS HIGHER Paper 1 (Non-calculator) NATIONAL QUALIFICATIONS 2014 TUESDAY, 6 MAY 1.00 PM 2.30 PM

Homework 2 Solutions

ENGINEERING COUNCIL DYNAMICS OF MECHANICAL SYSTEMS D225 TUTORIAL 1 LINEAR AND ANGULAR DISPLACEMENT, VELOCITY AND ACCELERATION

Math 0306 Final Exam Review

PHP Tutorial From beginner to master

Part 1 Expressions, Equations, and Inequalities: Simplifying and Solving

Experiment 4 ~ Newton s Second Law: The Atwood Machine

Objective: To distinguish between degree and radian measure, and to solve problems using both.

Microsoft Excel 2010 Part 3: Advanced Excel

ECDL / ICDL Spreadsheets Syllabus Version 5.0

1. Units of a magnetic field might be: A. C m/s B. C s/m C. C/kg D. kg/c s E. N/C m ans: D

1 One Dimensional Horizontal Motion Position vs. time Velocity vs. time

Exponents. Exponents tell us how many times to multiply a base number by itself.

Solve addition and subtraction word problems, and add and subtract within 10, e.g., by using objects or drawings to represent the problem.

Grade 8 Mathematics Measurement: Lesson 6

16 Circles and Cylinders

Problem Set V Solutions

Pythagoras Theorem. Page I can identify and label right-angled triangles explain Pythagoras Theorem calculate the hypotenuse

Welcome to Physics 40!

MATHEMATICS Y6 Geometry 6750 Use co-ordinates and extend to 4 quadrants Equipment MathSphere

1.3.1 Position, Distance and Displacement

Examples of Functions

Programming with Mathcad Prime

Lessons 6 and 7 Foam Bridge Experiment- Forces and Stresses Lab

A GUIDE TO PROCESS MAPPING AND IMPROVEMENT

PRELAB: NEWTON S 3 RD LAW AND MOMENTUM CONSERVATION

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

First published in 2013 by the University of Utah in association with the Utah State Office of Education.

AP Calculus AB 2005 Free-Response Questions

WORK SCHEDULE: MATHEMATICS 2007

Mathematics Task Arcs

Learning Module 4 - Thermal Fluid Analysis Note: LM4 is still in progress. This version contains only 3 tutorials.

Lab #4 - Linear Impulse and Momentum

Calculating Area, Perimeter and Volume

2667A - Introduction to Programming

Accelerometers: Theory and Operation

Physics 1120: Simple Harmonic Motion Solutions

SolidWorks: Mirror, Revolve, and. Introduction to Robotics

Lecture 07: Work and Kinetic Energy. Physics 2210 Fall Semester 2014

3 e) x f) 2. Precalculus Worksheet P Complete the following questions from your textbook: p11: # Why would you never write 5 < x > 7?

Lab 2: Vector Analysis

Problem Solving Basics and Computer Programming

Algebra Geometry Glossary. 90 angle

Transcription:

ChE-1800 H-2: Flowchart Diagrams (last updated January 13, 2013) This handout contains important information for the development of flowchart diagrams Common Symbols for Algorithms The first step before developing any program in Matlab or other programming software is to sketch the program through a flowchart. Building a flowchart or algorithm decreases the time employed to construct the program and reduces the number or errors that we make in the program. The algorithm must underline the logic of the program. It is a way to make our thoughts clear before writing any lines in the code. Common Flowchart Symbols Start or End Program (and/or loops) Input data (by user) Process, calculate, etc Making Decisions Print The symbols in the flowchart diagram are connected by arrows, which indicate the flow of the information in the program. All the input variables should be given at the beginning of the program. The answer of the problem should be printed at the end of the program. It is important that you define the variables used in the flowchart diagram in a legend. The example given below shows the flowchart diagram for an algorithm to calculate the area of a circle given the radius: Start Legend: r r: radius of circumference, cm r: radius of circle, cm A: A: area of of circumference, circle, cm 2 cm 2 A = π r 2 A 1 end

Sometimes the flowchart diagrams are too long to fix in a continuous vertical line. If that is the case you can breakdown the diagram by using Greek letters and continue writing the diagram in the horizontal space. The example given below shows how to breakdown the flowchart diagram to calculate the area of a circumference to utilize the horizontal space of the paper. Start α A r end A = π r 2 α Legend: r: r: radius radius of of circumference, circle, cm cm A: A: area of of circumference, circle, cm 2 cm 2 Everybody thinks in a different way, therefore, there are different ways to achieve a solution for a problem when programming. The best way to learn how to build flowchart diagrams is by solving problems. Let us solve the exercises given below together: 1. Class Exercise: Simple Flowchart Diagram. Develop a flowchart diagram to calculate the volume of a gas using ideal gas law. Relational operators: Matlab uses the following relational operators. The relational operators are used only in decision making loops and while loops. They are not arithmetic operators. <: less than, for example A < B means that A is less than B >: greater than, for example A > B means that A is greater than B <=: less than or equal to, for example A <= B means that A is less than or equal to B >=: greater than or equal to, for example A >= B means that A is greater than or equal to B = =: equal to, for example A = = B means that A is equal to B ~ =: not equal to, for example A ~ = B means that A is not equal to B Decision making (logic commands). Most of the time the user has to choose among multiple options, in this case making decisions commands must be used. The decision symbol should be used (this command is used to select from among 2 or more options). This structure is known in Matlab as the if/else syntax. We will practice the syntax structure in the computer lab. During the lecture we are going to focus on the development of the flowchart diagram only. An example of a decision making loop is given below. 2

x = 1 yes If x== 0 no Si Hola means hello in Spanish end if Can you tell what the algorithm will do by looking at the above flowchart diagram? Notice that the decision making loop starts and finishes with specific symbols. Would the algorithm work if the flowchart diagram is written like this? Justify your answer x = 1 yes If x= 0 no Si Hola means hello in Spanish end if 2. Class Exercise: Use of decision making. Develop a flowchart diagram that will allow the user to calculate any of the following information by using ideal gas law: temperature, volume, and pressure. While loops. This structure is used to repeat a set of commands an undetermined number of times. The number of times the loop will be repeated (loop counter variable) should be defined in the program in the while command. It is a good practice to set a default variable to the loop counter variable to guarantee that your loop will run. The while loop starts and ends with the symbol IMPORTANT: The loop counter variable should change inside the while loop otherwise the loop will run forever. Below are given three different cases of the use of the while loop. Can you tell what the algorithm will 3

print by looking at the different flowchart diagrams? Case A Case B Case C While (t<4) While (t<=4) While (t<=4) t=t*2 t=t*2 3. Class Exercise: Use of while loop. The ideal gas law is only valid at low pressures. Develop a flowchart diagram that will allow the user to calculate the volume of the gas using ideal gas low only is the pressure is lower than 2 atm. Use a while loop to do this. If the pressure is higher than 2 atm the program should print an error message Pressure higher than 2 atm, ideal gas law is not valid for loops. This structure is used to repeat a set of commands a determined number of times. The number of times the loop will be repeated (loop counter variable) should be defined in the program in the for command. The for loop starts and ends with the symbol The range for the loop counter is set as follows: for n=1:5 (This means that n will start at 1 and the loop will be repeated until n = 5. Each time the loop runs it automatically adds 1 to the loop counter n If you want a different increment instead of 1 you should use the following for s = 1.0: -0.1: 0.0 This means that the loop will start with s = 1.0, it will decrease the value of s until s = 0 by subtracting -0.1 each time the loop is repeated. Can you tell what the algorithm will print by looking at the flowchart diagram? Length = 2 for (n=1:0.5:length) y=y+n 4 End for n, y

Can you tell what the algorithm will do now by looking at the flowchart diagram? What is the difference between the two diagrams? Length = 2 y=0 for (n=1:0.5:length) y=y+n End for 4. Class Exercise: Use of for loop. Write a flowchart diagram for a program that will perform the following operation 4 x = y i= 1 i n, y only if y is an even number. The value y should be provided by the user. If the variable y is not an even number the program should print an error message error y is not an even number 5. Proposed Exercise: Repeat exercise 3 but using a making decision loop instead of a while loop. 6. Proposed Exercise: The velocity, v, and the distance, d, as a function of time, of a car that accelerates from rest at constant acceleration, a, are given by: 1 2 v= at d= at 2 Write a flowchart diagram to determine v and d as every second for the first 10 seconds for a car with acceleration of a = 1.55 m/s 2. The program should be able to print the velocity and distance every 2 seconds. 5