Lecture 2 Selection and Looping. Program control, if-else, logical expressions, for loop
|
|
- Jeffery Johnston
- 5 years ago
- Views:
Transcription
1 Lecture 2 Selection and Looping Program control, if-else, logical expressions, for loop
2 Overview Review Program control if-else statement Relational and logical operators Logical expressions for loop statement
3 How to write a program? 1. Read the problem statement, and identify The input and its range The output The relationship between the input and the output (how to compute the output) [Compreh] 2. Write your thoughts as a sequence of steps. [Algorithm] 3. Convert these steps to Code. [Program] 4. Test your code and compare your program result against a human result. [Testing]
4 Calculate area of a rectangle (Algorithm Program) 1. Get height h h=input( enter height: ); 2. Get width w w=input( enter width: ); 3. Calculate area = h * w area = h * w; 4. Display area disp (area);
5 Program Control How to control the flow of the program? To make the program takes decision To execute some statements and not the other based on the input data or other condition. How to make some statements executed several times.
6 Print the maximum of two numbers (Algorithm and Program) 1. Get number1 as X X=input( enter num1: ); 2. Get number2 as Y Y=input( enter num2: ); 3. If X > Y if X>Y display X disp(x); Otherwise else display Y disp(y);
7 Print the maximum of two numbers % printmax.m X=input( enter num1: ); Y=input( enter num2: ); if X>Y disp(x); else disp(y); (Program and Testing) >>printmax enter num1: 5 enter num2: >>printmax enter num1: 8 enter num2: 3 8 X Y X Y
8 Print two number in ascing order (Algorithm Program) 1. Get number1 as X X=input( enter num1: ); 2. Get number2 as Y Y=input( enter num2: ); 3. If X > Y if X>Y display Y, X disp(y); disp(x); Otherwise else display X, Y disp(x); disp(y);
9 Print two number in ascing order % order2.m X=input( enter num1: ); Y=input( enter num2: ); if X>Y disp(y); disp(x); else disp(x); disp(y); (Program and Testing) >>order2 enter num1: 5 enter num2: >>order2 enter num1: 8 enter num2: X Y
10 If-else statement if condition % do this part if condition is true else %do this part if the condition is false Condition (use relational operators): >, <, >=, <=, ==, ~=
11 Relational Operators Relational operators test the Relationship between two operands (which can be expressions) They are a Truth Statement, and resolve to either True (1) or False (0) Operator Operation == Equal to ~= Not equal to > Greater than >= Greater than or equal to < Less than <= Less than or equal to
12 Logical Operators Relational operators are binary operators so they can have only two operands To have a more complicated condition, we need to use logical operators Logic Operators can combine truth statements together in helpful ways. (and, or, not) Inputs and or not A B A && B A B ~A false false false false true false true false true true true false false true false true true true true false
13 Logical Expressions Examples Write the if condition for the following cases: 1. Check if x > y > z if x>y && y>z 2. Check if x is greater than y or less than or equal to z if x>y x <=z 3. Check if x does not equal y but equal z if x~=y && x==z 4. Check if x is even if rem(x,2)==0 5. Check if y is positive if y>0
14 Repeat a program N times for i=1:1:5 Iteration counter First counter value Step value X=input( enter num1: ); Y=input( enter num2: ); if X>Y disp(x); else disp(y); Last counter value
15 Try it in MATLAB for i=1:1:5 X=input( enter num1: ); Y=input( enter num2: ); if X>Y disp(x); else disp(y); i X Y? How many times these loops will run: for i=1:2:10 for z=10:2:20 for a=10:-2:1 for x=1:10
16 Calculate sum from 1 to N (Program) N=input( enter a number: ); sum=0; for i=1:n sum=sum+i; disp(sum); N i sum ? How to sum only even numbers
17 Calculate factorial of a number N (Program) N=input( enter a number: ); f=1; for i=1:n f=f*i; disp(f); N i f
18 What this program does? N=input( enter a number: ); sum=0; for i=1:n x=input( enter a value: ); sum=sum+x; disp(sum); N i x sum ? How to compute the average of N numbers
19 Sum only positive numbers? N=input( enter a number: ); sum=0; for i=1:n x=input( enter a value: ); if x>0 sum=sum+x; disp(sum); N i x sum
20 Sum and Average positive numbers? N=input( enter a number: ); sum=0; c=0; for i=1:n x=input( enter a value: ); if x>0 sum=sum+x; c=c+1; End Avg=sum/c; C is used to count positive numbers disp(sum); Disp(Avg); N i x sum c
21 Thank You Course Site: Computers for Engineers GENN004
Lecture 3 Algorithms Part I. Calculating sum and average, Getting the maximum, Counting occurrences, Finding matches
Lecture 3 Algorithms Part I Calculating sum and average, Getting the maximum, Counting occurrences, Finding matches Overview Calculating sum & average of students grades Getting the maximum Counting number
More informationLecture 4 Advanced Selection. Nested if-else, if-elseif, operators precedence
Lecture 4 Advanced Selection Nested if-, if-if, operators precedence Overview if- statement Nested if- statements If-if statement Operators Precedence If- statement if condition % do this part if condition
More informationRepetition Structures Chapter 9
Sum of the terms Repetition Structures Chapter 9 1 Value of the Alternating Harmonic Series 0.9 0.8 0.7 0.6 0.5 10 0 10 1 10 2 10 3 Number of terms Objectives After studying this chapter you should be
More informationStep by step set of instructions to accomplish a task or solve a problem
Step by step set of instructions to accomplish a task or solve a problem Algorithm to sum a list of numbers: Start a Sum at 0 For each number in the list: Add the current sum to the next number Make the
More informationA B C ((NOT A) AND B) OR C
chapter5 pg 184 1,2,6 1 Assuming that x=1 and y=2, determine the value of each of the following Boolean expressing: (x=1) AND(y=3) (x1) Not[(x=1) AND (y=2)] Answer: False True False 2 Assume
More informationLecture 8 Programmer-Defined Functions in MATLAB
Lecture 8 Programmer-Defined Functions in MATLAB Outline Why programmer-defined functions? Simple Custom Functions Script vs Function Modular Programming Why programmer-defined functions? % Calculate x!/y!
More informationCS111: PROGRAMMING LANGUAGE II
CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A
More informationCOMPUTER SCIENCE PAPER 1
COMPUTER SCIENCE PAPER 1 (THEORY) (Maximum Marks: 70) (Time allowed: Three hours) (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time.)
More informationAPPM 2460: Week Three For, While and If s
APPM 2460: Week Three For, While and If s 1 Introduction Today we will learn a little more about programming. This time we will learn how to use for loops, while loops and if statements. 2 The For Loop
More informationProgramming for Experimental Research. Flow Control
Programming for Experimental Research Flow Control FLOW CONTROL In a simple program, the commands are executed one after the other in the order they are typed. Many situations require more sophisticated
More informationTest #2 October 8, 2015
CPSC 1040 Name: Test #2 October 8, 2015 Closed notes, closed laptop, calculators OK. Please use a pencil. 100 points, 5 point bonus. Maximum score 105. Weight of each section in parentheses. If you need
More information3. According to universal addressing, what is the address of vertex d? 4. According to universal addressing, what is the address of vertex f?
1. Prove: A full m-ary tree with i internal vertices contains n = mi + 1 vertices. 2. For a full m-ary tree with n vertices, i internal vertices, and l leaves, prove: (i) i = (n 1)/m and l = [(m 1)n +
More informationLoops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017
Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The
More informationProgramming in MATLAB
8. Program Flow and Recursion Faculty of mathematics, physics and informatics Comenius University in Bratislava November 25th, 2015 Program Flow Program Flow in the first lecture: one command at a time
More informationBasic exercises. Array exercises. 1. x = 32:2: x = [ ] a = x + 16 b = x(1:2:end) + 3 c = sqrt(x) or c = x.^(0.5) d = x.^2 or d = x.
Basic exercises 1. x = 32:2:75 2. x = [2 5 1 6] a = x + 16 b = x(1:2:) + 3 c = sqrt(x) or c = x.^(0.5) d = x.^2 or d = x.*x 3. x = [3 2 6 8]', y = [4 1 3 5]' a = y + sum(x) b = x.^y c = x./y z = x.*y w
More informationLECTURE 5 Control Structures Part 2
LECTURE 5 Control Structures Part 2 REPETITION STATEMENTS Repetition statements are called loops, and are used to repeat the same code multiple times in succession. The number of repetitions is based on
More informationChapter 4: Programming with MATLAB
Chapter 4: Programming with MATLAB Topics Covered: Programming Overview Relational Operators and Logical Variables Logical Operators and Functions Conditional Statements For Loops While Loops Debugging
More informationRelational & Logical Operators, Selection Statements
Relational & Logical Operators, Selection Statements by Ahmet Sacan selection statements, branching statements, condition, relational expression, Boolean expression, logical expression, relational operators,
More informationSelections. Zheng-Liang Lu 91 / 120
Selections ˆ Selection enables us to write programs that make decisions on. ˆ Selection structures contain one or more of the if, else, and elseif statements. ˆ The end statement denotes the end of selection
More informationSequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;
Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The
More informationIntroduction to Functional Programming
Introduction to Functional Programming Xiao Jia xjia@cs.sjtu.edu.cn Summer 2013 Scheme Appeared in 1975 Designed by Guy L. Steele Gerald Jay Sussman Influenced by Lisp, ALGOL Influenced Common Lisp, Haskell,
More informationMore About Factoring Trinomials
Section 6.3 More About Factoring Trinomials 239 83. x 2 17x 70 x 7 x 10 Width of rectangle: Length of rectangle: x 7 x 10 Width of shaded region: 7 Length of shaded region: x 10 x 10 Area of shaded region:
More informationProgramming 1. Script files. help cd Example:
Programming Until now we worked with Matlab interactively, executing simple statements line by line, often reentering the same sequences of commands. Alternatively, we can store the Matlab input commands
More information17 USING THE EDITOR AND CREATING PROGRAMS AND FUNCTIONS
17 USING THE EDITOR AND CREATING PROGRAMS AND FUNCTIONS % Programs are kept in an m-file which is a series of commands kept in the file that is executed from MATLAB by typing the program (file) name from
More informationBasic circuit analysis and design. Circuit analysis. Write algebraic expressions or make a truth table
Basic circuit analysis and design Circuit analysis Circuit analysis involves figuring out what some circuit does. Every circuit computes some function, which can be described with Boolean expressions or
More informationStandard Forms of Expression. Minterms and Maxterms
Standard Forms of Expression Minterms and Maxterms Standard forms of expressions We can write expressions in many ways, but some ways are more useful than others A sum of products (SOP) expression contains:
More informationIntroduction to MATLAB
Introduction to MATLAB Dr./ Ahmed Nagib Mechanical Engineering department, Alexandria university, Egypt Spring 2017 Chapter 4 Decision making and looping functions (If, for and while functions) 4-1 Flowcharts
More informationLecture Transcript While and Do While Statements in C++
Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some
More informationStandard Boolean Forms
Standard Boolean Forms In this section, we develop the idea of standard forms of Boolean expressions. In part, these forms are based on some standard Boolean simplification rules. Standard forms are either
More informationIntroduction to Boolean logic and Logical Gates
Introduction to Boolean logic and Logical Gates Institute of Statistics Fall 2014 We saw the importance of the binary number system for data representation in a computer system. We ll see that the construction
More informationIntroduction to C++ Lecture Set 2. Introduction to C++ Week 2 Dr Alex Martin 2013 Slide 1
Introduction to C++ Lecture Set 2 Introduction to C++ Week 2 Dr Alex Martin 2013 Slide 1 More Arithmetic Operators More Arithmetic Operators In the first session the basic arithmetic operators were introduced.
More informationHenry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012
Henry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012 1 Digital vs Analog Digital signals are binary; analog
More informationBounded, Closed, and Compact Sets
Bounded, Closed, and Compact Sets Definition Let D be a subset of R n. Then D is said to be bounded if there is a number M > 0 such that x < M for all x D. D is closed if it contains all the boundary points.
More informationINTRODUCTION OF LOOPS
INTRODUCTION OF LOOPS For Loop Example 1: based on an existing array L, create another array R with each element having the absolute value of the corresponding one in array L. Input: L = [11-25 32-2 0
More informationfalse, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4
1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 44
More informationVariables and Assignments
Variables and Assignments ˆ A variable is used to keep a value or values. ˆ A box which contains something. ˆ In most languages, a statement looks like var = expression, where var is a variable and expression
More informationCS February 17
Discrete Mathematics CS 26 February 7 Equal Boolean Functions Two Boolean functions F and G of degree n are equal iff for all (x n,..x n ) B, F (x,..x n ) = G (x,..x n ) Example: F(x,y,z) = x(y+z), G(x,y,z)
More informationProgramming for Engineers Iteration
Programming for Engineers Iteration ICEN 200 Spring 2018 Prof. Dola Saha 1 Data type conversions Grade average example,-./0 class average = 23450-67 893/0298 Grade and number of students can be integers
More informationLecture 3 (02/06, 02/08): Condition Statements Decision, Operations & Information Technologies Robert H. Smith School of Business Spring, 2017
Lecture 3 (02/06, 02/08): Condition Statements Decision, Operations & Information Technologies Robert H. Smith School of Business Spring, 2017 K. Zhang BMGT 404 The modulus operator It works on integers
More informationCOMPUTER APPLICATION
Total No. of Printed Pages 16 HS/XII/A.Sc.Com/CAP/14 2 0 1 4 COMPUTER APPLICATION ( Science / Arts / Commerce ) ( Theory ) Full Marks : 70 Time : 3 hours The figures in the margin indicate full marks for
More informationQUESTION BANK FOR TEST
CSCI 2121 Computer Organization and Assembly Language PRACTICE QUESTION BANK FOR TEST 1 Note: This represents a sample set. Please study all the topics from the lecture notes. Question 1. Multiple Choice
More informationNumerical Methods in Engineering Sciences
Numerical Methods in Engineering Sciences Lecture 1: Brief introduction to MATLAB Pablo Antolin pablo.antolinsanchez@unipv.it October 29th 2013 How many of you have used MATLAB before? How many of you
More information60-265: Winter ANSWERS Exercise 4 Combinational Circuit Design
60-265: Winter 2010 Computer Architecture I: Digital Design ANSWERS Exercise 4 Combinational Circuit Design Question 1. One-bit Comparator [ 1 mark ] Consider two 1-bit inputs, A and B. If we assume that
More informationRepetition Algorithms
Repetition Algorithms Repetition Allows a program to execute a set of instructions over and over. The term loop is a synonym for a repetition statement. A Repetition Example Suppose that you have been
More informationCOMPUTER SCIENCE Paper 1
COMPUTER SCIENCE Paper 1 (THEORY) (Three hours) Maximum Marks: 70 (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) -----------------------------------------------------------------------------------------------------------------------
More informationOutline. Helper Functions and Reuse. Conditionals. Evaluation Rules for cond. Design Recipe with cond. Compound Data
Outline Helper Functions and Reuse Conditionals Evaluation Rules for cond Design Recipe with cond Compound Data 1 Designing Programs Design recipe As outlined last lecture 2 Designing Programs Design recipe
More informationREPETITIVE EXECUTION: LOOPS
Contents REPETITIVE EXECUTION: LOOPS... 1 for Loops... 1 while Loops... 6 The break and continue Commands... 8 Nested Loops... 10 Distinguishing Characteristics of for and while Loops Things to Remember...
More informationSoftware often repeats a set of instructions over and over again. This repetition continues until some condition is met.
Software often repeats a set of instructions over and over again. This repetition continues until some condition is met. A programming statement that does this is called a : repeat "Enter user id and password"
More informationProgramming in MATLAB Part 2
Programming in MATLAB Part 2 A computer program is a sequence of computer commands. In a simple program the commands are executed one after the other in the order they are typed. MATLAB provides several
More information: Principles of Imperative Computation Victor Adamchik. Practice Exam - I
15-122 Practice Exam - I Page 1 of 10 15-122 : Principles of Imperative Computation Victor Adamchik Practice Exam - I Name: Andrew ID: Answer the questions in the space provided following each question.
More informationMulti-Operand Addition Ivor Page 1
Multi-Operand Addition 1 Multi-Operand Addition Ivor Page 1 9.1 Motivation The motivation for multi-operand adders comes from the need for innerproduct calculations and multiplication (summing the partial
More informationIntroduction to Control Structures
Introduction to Control Structures Aniel Nieves-González Institute of Statistics Spring 2014 Logical and relational operators Let x be a boolean variable, i.e., it can only be {0, 1} ({TRUE, FALSE}). For
More informationBits and Bytes. How do computers compute?
Bits and Bytes How do computers compute? Representing Data All data can be represented with: 1s and 0s on/of true/false Numbers? Five volunteers... Binary Numbers Positional Notation Binary numbers use
More informationSBT 645 Introduction to Scientific Computing in Sports Science #3
SBT 645 Introduction to Scientific Computing in Sports Science #3 SERDAR ARITAN serdar.aritan@hacettepe.edu.tr Biyomekanik Araştırma Grubu www.biomech.hacettepe.edu.tr Spor Bilimleri Fakültesi www.sbt.hacettepe.edu.tr
More informationAnnouncements. Lab Friday, 1-2:30 and 3-4:30 in Boot your laptop and start Forte, if you brought your laptop
Announcements Lab Friday, 1-2:30 and 3-4:30 in 26-152 Boot your laptop and start Forte, if you brought your laptop Create an empty file called Lecture4 and create an empty main() method in a class: 1.00
More informationCEMTool Tutorial. Control statements
CEMTool Tutorial Control statements Overview This tutorial is part of the CEMWARE series. Each tutorial in this series will teach you a specific topic of common applications by explaining theoretical concepts
More informationBoolean algebra, conditional statements, loops.
Boolean algebra, conditional statements, loops. Eugeniy E. Mikhailov The College of William & Mary Lecture 04 Eugeniy Mikhailov (W&M) Practical Computing Lecture 04 1 / 19 Boolean algebra Variable of valuable
More informationSelection Statements
Selection Statements by Ahmet Sacan selection statements, branching statements, condition, relational expression, Boolean expression, logical expression, relational operators, logical operators, truth
More informationIEEE Floating-Point Representation 1
IEEE Floating-Point Representation 1 x = ( 1) s M 2 E The sign s determines whether the number is negative (s = 1) or positive (s = 0). The significand M is a fractional binary number that ranges either
More information*Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* COMPUTER PROGRAMMING LECTURE 05 LOOPS IMRAN IHSAN
PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 05 LOOPS IMRAN IHSAN
More informationGM1.1 Consolidation Worksheet Answers
Cambridge Essentials Mathematics Support 8 GM1.1 Consolidation Worksheet Answers GM1.1 Consolidation Worksheet Answers 1 a a = 60 Angles on a straight line add to 180. b b = 150 Angles on a straight line
More informationfalse, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4
1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 44
More informationVerilog for Combinational Circuits
Verilog for Combinational Circuits Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C. Fall, 2014 ldvan@cs.nctu.edu.tw http://www.cs.nctu.edu.tw/~ldvan/
More informationMATLAB PROGRAMMING LECTURES
+` MATLAB PROGRAMMING LECTURES Lecture 1: Introduction to MATLAB 1.1Introduction MATLAB is a mathematical and graphical software package with numerical, graphical, and programming capabilities. It has
More informationCOMP519 Web Programming Lecture 21: Python (Part 5) Handouts
COMP519 Web Programming Lecture 21: Python (Part 5) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool Functions
More informationE40M Useless Box, Boolean Logic. M. Horowitz, J. Plummer, R. Howe 1
E40M Useless Box, Boolean Logic M. Horowitz, J. Plummer, R. Howe 1 Useless Box Lab Project #2 Motor Battery pack Two switches The one you switch A limit switch The first version of the box you will build
More informationCDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014)
CDA 3103 Computer Organization Exam 1 (Sep. 22th, 2014) Name: USF ID: Problem Points Score 1 10 2 10 3 15 4 15 5 10 6 20 otal 80 Exam Rules Use the back of the exam paper as necessary. But indicate clearly
More informationMore on control structures
Lecture slides for: Chapter 5 More on control structures Java Actually: A Comprehensive Primer in Programming Khalid Azim Mughal, Torill Hamre, Rolf W. Rasmussen Cengage Learning, 2008. ISBN: 978-1-844480-933-2
More informationCOMPUTER SCIENCE. Paper 1
COMPUTER SCIENCE Paper 1 (THEORY) Three hours (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) ----------------------------------------------------------------------------------------------------------------------------------
More informationCSE200 Lecture 6: RECURSION
Table of Contents Review of functions (using factorial example)... 1 Recursion... 1 Step by step run through of recursive factorial... 2 Recursion vs. iteration (for and while loops)... 3 Helper functions:...
More informationMATLAB PROGRAMMING LECTURES. By Sarah Hussein
MATLAB PROGRAMMING LECTURES By Sarah Hussein Lecture 1: Introduction to MATLAB 1.1Introduction MATLAB is a mathematical and graphical software package with numerical, graphical, and programming capabilities.
More informationChapter 1: Problem Solving Skills Introduction to Programming GENG 200
Chapter 1: Problem Solving Skills Introduction to Programming GENG 200 Spring 2014, Prepared by Ali Abu Odeh 1 Table of Contents Fundamentals of Flowcharts 2 3 Flowchart with Conditions Flowchart with
More informationLecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan
Lecture 08-1 Programming in C++ PART 1 By Assistant Professor Dr. Ali Kattan 1 The Conditional Operator The conditional operator is similar to the if..else statement but has a shorter format. This is useful
More informationLoops. by Ahmet Sacan
Loops by Ahmet Sacan looping statements, counted loops, conditional loops, action, iterate, loop or iterator variable, running sum, running product, factorial, preallocate, echo printing, nested loop,
More informationCISC 1600 Lecture 3.1 Introduction to Processing
CISC 1600 Lecture 3.1 Introduction to Processing Topics: Example sketches Drawing functions in Processing Colors in Processing General Processing syntax Processing is for sketching Designed to allow artists
More informationA Look Back at Arithmetic Operators: the Increment and Decrement
A Look Back at Arithmetic Operators: the Increment and Decrement Spring Semester 2016 Programming and Data Structure 27 Increment (++) and Decrement (--) Both of these are unary operators; they operate
More informationCS150 - Sample Final
CS150 - Sample Final Name: Honor code: You may use the following material on this exam: The final exam cheat sheet which I have provided The matlab basics handout (without any additional notes) Up to two
More informationWorksheet 6. Input and Output
Worksheet 6. Input and Output Most programs (except those that run other programs) contain input or output. Both fortran and matlab can read and write binary files, but we will stick to ascii. It is worth
More informationObjectives: 1- Bolean Algebra. Eng. Ayman Metwali
Objectives: Chapter 3 : 1- Boolean Algebra Boolean Expressions Boolean Identities Simplification of Boolean Expressions Complements Representing Boolean Functions 2- Logic gates 3- Digital Components 4-
More informationCOMP combinational logic 1 Jan. 18, 2016
In lectures 1 and 2, we looked at representations of numbers. For the case of integers, we saw that we could perform addition of two numbers using a binary representation and using the same algorithm that
More informationStructure Array 1 / 50
Structure Array A structure array is a data type that groups related data using data containers called fields. Each field can contain any type of data. Access data in a structure using dot notation of
More informationEP375 Computational Physics
EP375 Computational Physics Topic 1 MATLAB TUTORIAL BASICS Department of Engineering Physics University of Gaziantep Feb 2014 Sayfa 1 Basic Commands help command get help for a command clear all clears
More informationfunction [s p] = sumprod (f, g)
Outline of the Lecture Introduction to M-function programming Matlab Programming Example Relational operators Logical Operators Matlab Flow control structures Introduction to M-function programming M-files:
More informationOrdinary Differential Equation Solver Language (ODESL) Reference Manual
Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE
More informationCS1004: Intro to CS in Java, Spring 2005
CS4: Intro to CS in Java, Spring 25 Lecture #8: GUIs, logic design Janak J Parekh janak@cs.columbia.edu Administrivia HW#2 out New TAs, changed office hours How to create an Applet Your class must extend
More informationAssignment (3-6) Boolean Algebra and Logic Simplification - General Questions
Assignment (3-6) Boolean Algebra and Logic Simplification - General Questions 1. Convert the following SOP expression to an equivalent POS expression. 2. Determine the values of A, B, C, and D that make
More informationChapter 4. Combinational Logic. Dr. Abu-Arqoub
Chapter 4 Combinational Logic Introduction N Input Variables Combinational Logic Circuit M Output Variables 2 Design Procedure The problem is stated 2 The number of available input variables & required
More informationCompiler Construction
Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-17/cc/ Generation of Intermediate Code Outline of Lecture 15 Generation
More informationfalse, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4
1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 44
More informationLecture #21 March 31, 2004 Introduction to Gates and Circuits
Lecture #21 March 31, 2004 Introduction to Gates and Circuits To this point we have looked at computers strictly from the perspective of assembly language programming. While it is possible to go a great
More informationMULTIPLE OPERAND ADDITION. Multioperand Addition
MULTIPLE OPERAND ADDITION Chapter 3 Multioperand Addition Add up a bunch of numbers Used in several algorithms Multiplication, recurrences, transforms, and filters Signed (two s comp) and unsigned Don
More informationReview: Standard forms of expressions
Karnaugh maps Last time we saw applications of Boolean logic to circuit design. The basic Boolean operations are AND, OR and NOT. These operations can be combined to form complex expressions, which can
More informationAlgorithms. Abdelghani Bellaachia, CSCI 1121 Page: 1
Algorithms 1. Objectives... 2 2. Design You Solution... 2 3. Structure of an algorithm:... 3 4. Pseudocode:... 4 5. Example... 5 6. Selection or Conditional Execution... 8 7. Looping or Iteration... 9
More informationProgramming in MATLAB
Programming in MATLAB Scripts, functions, and control structures Some code examples from: Introduction to Numerical Methods and MATLAB Programming for Engineers by Young & Mohlenkamp Script Collection
More informationLECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE
Department of Software The University of Babylon LECTURE NOTES ON PROGRAMMING FUNDAMENTAL USING C++ LANGUAGE By Collage of Information Technology, University of Babylon, Iraq Samaher_hussein@yahoo.com
More information7 Control Structures, Logical Statements
7 Control Structures, Logical Statements 7.1 Logical Statements 1. Logical (true or false) statements comparing scalars or matrices can be evaluated in MATLAB. Two matrices of the same size may be compared,
More informationCS 221 Lecture. Tuesday, 11 October 2011
CS 221 Lecture Tuesday, 11 October 2011 "Computers in the future may weigh no more than 1.5 tons." - Popular Mechanics, forecasting the relentless march of science, 1949. Today s Topics 1. Announcements
More informationSOLVING SIMULTANEOUS EQUATIONS. Builtin rref(a) EXAMPLE E4.1 Solve Corresponding augmented matrix 2x 4y 2 a 242 x 3y 3
Lecture 4 matrices and progressions Open Lecture 4 on class website: www.math.hawaii.edu/190 ELEMENTARY ROW OPERATIONS swap mult add_mult Given a matri, there are three types of elementary row operations:
More informationAlice. Coverage. Mathematical Expressions, Conditional Statements, Control Structures. Arithmetic Expressions Built-in Functions Conditional Execution
Alice Mathematical Expressions, Conditional Statements, Control Structures Coverage Arithmetic Expressions Built-in Functions Conditional Execution If/Then Statements Control Structures Loops 1 Functions
More informationENGR 1181 MATLAB 09: For Loops 2
ENGR 1181 MATLAB 09: For Loops Learning Objectives 1. Use more complex ways of setting the loop index. Construct nested loops in the following situations: a. For use with two dimensional arrays b. For
More information