Ch 7-8 Arithmetic Logical Operators

Slides:



Advertisements
Similar presentations
Chapter 4: Control Structures I (Selection)
Advertisements

Programming in R 2007 R 統計軟體研習會 蔡政安 Associate Professor Department of Public Health & Biostatistics Center China Medical University.
Fall 2004ENGR 111A MatLab – Palm Chapter 4, Part 2 The if and switch structure Class 10.1 Sections: 4.4 and 4.6.
Copyright 2010 by Pearson Education Building Java Programs Chapter 4 Lecture 4-2: Advanced if/else ; Cumulative sum reading: 4.1, 4.3, 4.5; "Procedural.
1 Ch 7-8 lArithmetic lLogical Operators © Fall 2004 Don Edwards and the University of South Carolina.
Week 10 Recap CSE 115 Spring For-each loop When we have a collection and want to do something to all elements of that collection we use the for-each.
Announcements Quiz 1 Posted on blackboard Handed Back (and Gone Over)Next Monday “Only a Quiz” Counts 5% of Final Grade Exam 1 Counts 10%
Visual C++ Programming: Concepts and Projects
1 Ch 9-10 lSubsetting lOrdering lArray operations lIteration © Fall 2004 Don Edwards and the University of South Carolina.
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
Decisions – Chapter 3 IPC144 Week 2. IPC144 Introduction to Programming Using C Week 2 – Lesson 2 (Pages 12 to 18 in IPC144 Textbook)
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
Decision II. CSCE 1062 Outline  Boolean expressions  switch statement (section 4.8)
Flow of Control Part 1: Selection
MS3304: Week 6 Conditional statements. Overview The flow of control through a script Boolean Logic Conditional & logical operators Basic decision making.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
Computer Science: A Structured Programming Approach Using C1 5-2 Two-Way Selection The decision is described to the computer as a conditional statement.
Computer Science: A Structured Programming Approach Using C1 5-2 Two-Way Selection The decision is described to the computer as a conditional statement.
Chapter 4 Controlling Execution CSE Objectives Evaluate logical expressions –Boolean –Relational Change the flow of execution –Diagrams (e.g.,
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Computer Programming TCP1224 Chapter 5 The Selection Structure.
Chapter 6 - Repetition. while Loop u Simplest loop u Two parts: test expression and loop body u Pre-tested loop –Execute loop body if test true –Bypass.
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
COMP Loop Statements Yi Hong May 21, 2015.
Programming Language C++ Lecture 3. Control Structures  C++ provides control structures that serve to specify what has to be done to perform our program.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 4: Control Structures (Part 2) Xiang Lian The University of Texas – Pan American Edinburg, TX
Intelligent Numerical Computation1 Numerical Analysis Basic structures of a flowchart Solving a nonlinear equation with one variable Bisection method Newton.
Conditional statements and boolean expressions Arithmetic, relational and logical operators.
CHAPTER 3 CONTROL STRUCTURES ( SELECTION ) I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
USING CONDITIONAL CODE AMIR KHANZADA. Conditional Statement  Conditional statements are the set of commands used to perform different actions based on.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand how decisions are made in a computer ❏ To understand the logical.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Topic : While, For, Do-While Loop Guided By : Branch : Batch :
Sequence, Selection, Iteration The IF Statement
CMPT 201 if-else statement
Selection—Making Decisions
CHAPTER 5: SELECTION STRUCTURES: if and switch STATEMENTS
Chapter 5: Repetition Structures
CiS 260: App Dev I Chapter 4: Control Structures II.
Ch 7: JavaScript Control Statements I.
An Introduction to Programming with C++ Fifth Edition
Control Structures.
Introduction to MATLAB
Building Java Programs
OPERATORS (2) CSC 111.
2-1 Making Decisions Sample assignment statements
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
Vectorized Code, Logical Indexing
Control Structures: for & while Loops
3 Control Statements:.
Pages:51-59 Section: Control1 : decisions
Chapter 8: More on the Repetition Structure
CS139 October 11, 2004.
Visual Basic – Decision Statements
Selection Statements.
Introduction to Matlab
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Microsoft Visual Basic 2005: Reloaded Second Edition
Building Java Programs
Building Java Programs
Ch 9-10 Subsetting Ordering Array operations Iteration
Chapter 5 Decisions.
Chapter 4: Boolean Expressions, Making Decisions, and Disk Input and Output Prof. Salim Arfaoui.
Expressions and assignments
Pages:51-59 Section: Control1 : decisions
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.
Presentation transcript:

Ch 7-8 Arithmetic Logical Operators © Fall 2004 Don Edwards and the University of South Carolina

7 Arithmetic Basic operators (+,-,…) Typical “calculator” functions (exp, log, sqrt, sum, prod, …) Matrices Elementwise and matrix operators Be careful of object type Maple users may be underwhelmed

8 Logical Objects and Operators TRUE or FALSE values Logical operators (>,<,>=,!,…) Subsetting and conditional execution Compound (&,|,..) and sequential (&&,||,…) operators With sequential operators, the second logical comparison can be skipped if the first is true. Not really evident in real time.

8 Logical Operators as functions xor any, all, identical,… Avoid == with numeric variables Don’s old notes had an advanced discussion of testing equivalency of numeric variables. Class Exercise 3 touches on this topic as well.

8 Conditional Execution if{…} else if{…} else {…} The if() statement works elementwise Wait till Chapter 10: Iteration ifelse() Excel recoding The syntax for if/else if/else is highly structured—very un-R like. Class Exercise 3 discusses ifelse()