1 Chapter 3: Loops and Logic. 2 Control Statements If statement Example NumberCheck.java Relational operators (, >=, ==, !=) Using code blocks with If.

Slides:



Advertisements
Similar presentations
INTEC CS160 - Jeanine Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 3 Control Structures and Data Files.
Advertisements

Java Control Statements
Introduction to C Programming
Fundamental Programming Structures in Java: Control Flow, Arrays and Vectors.
1 Control Statements Lecture 6 from Chapter 5. 2 Three principles of OOP- Encapsulation Encapsulation allows changes to code to be more easily made. It.
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
COMP1180 Review Date: 4 March, 2009 Time: 10:30am - 12:20pm Venue: –CS students -- FSC801C and FSC801D –IS and other students -- OEE1017 Remarks: – 1)
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
Chapter 6 - Repetition. Introduction u Many applications require certain operations to be carried out more than once. Such situations require repetition.
Logical Operators Java provides two binary logical operators (&& and ||) that are used to combine boolean expressions. Java also provides one unary (!)
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Logical and Relational Expressions Nested if statements.
CS 117 Spring 2002 Review for Exam 2 March 6, 2002 open book, 1 page of notes.
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
TODAY’S LECTURE Review Chapter 2 Go over exercises.
Day 4 Objectives Constructors Wrapper Classes Operators Java Control Statements Practice the language.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Control Structures – Selection Chapter 4 2 Chapter Topics  Control Structures  Relational Operators  Logical (Boolean) Operators  Logical Expressions.
DiagrammaticRepresentation Iteration Construct False True Condition Exit from Statement (s) loop Sequence construct Selection construct Statement 1 Statement.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II UTPA – Fall
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Additional Control Structures. Chapter 9 Topics Switch Statement for Multi-way Branching Do-While Statement for Looping For Statement for Looping Using.
Chapter 7 LOOPING OPERATIONS: ITERATION. Chapter 7 The Flow of the while Loop.
Chapter 8 Repetition Statements. Introduction Iteration - process of looping or the repetition of one or more statements Loop body - the statement, or.
Chapter 3. Outline Relational Operators Loops Decisions Logical Operators Precedence Summary.
Lecture 4 Control Structures MIT – AITI What are Control Structures? Control structures are a way to alter the natural sequence of execution in.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
Control Statements in C 1.Decision making statements 2.Looping statements 3.Branching statements
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Chapters 1-5 Review C++ Class. Chapter 1 – the big picture Objects Class Inheritance Reusability Polymorphism and Overloading.
Fundamental Programming Fundamental Programming for Loops.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
Working with Loops, Conditional Statements, and Arrays.
Chapter 9 Control Structures.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
1 Programming in C++ Dale/Weems/Headington Chapter 9 Additional Control Structures (Switch, Do..While, For statements)
Program Structures Chapter 5. 5 Branching Allows different code to execute based on a conditional test. if, if-else, and switch statements.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Chapter 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
C Language 1 Program Looping. C Language2 Topics Program looping Program looping Relational operators / expressions Relational operators / expressions.
Session 2 Operators, Decisions and Loops. Objectives Operators Casting data Decision marking structures Loops break, continue, return.
Engineering Computing I Chapter 3 Control Flow. Chapter 3 - Control Flow The control-flow of a language specify the order in which computations are performed.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Looping Increment/Decrement Switch. Flow of Control Iteration/Switch Statements.
Lecture 3.1 Operators and Expressions Structured Programming Instructor: Prof. K. T. Tsang 1.
C Program Control September 15, OBJECTIVES The essentials of counter-controlled repetition. To use the for and do...while repetition statements.
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
CHAPTER 4 DECISIONS & LOOPS
Chapter 9 Repetition.
© 2016, Mike Murach & Associates, Inc.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Unit-1 Introduction to Java
Expressions and Control Flow in JavaScript
Chapter 19 JavaScript.
Control Structures – Selection
الحلقات التكرارية وجمل الدوران (loops)
Chapter 5 Repetition.
The University of Texas – Pan American
Chapter 9 Control Structures.
Java - Data Types, Variables, and Arrays
Professor Jodi Neely-Ritz CGS3460
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises UTPA – Fall 2012 This set of slides is revised from.
Program Control Topics While loop For loop Switch statement
Program Flow.
Fundamental Programming
Decisions, decisions, decisions
Controlling Program Flow
Presentation transcript:

1 Chapter 3: Loops and Logic

2 Control Statements If statement Example NumberCheck.java Relational operators (, >=, ==, !=) Using code blocks with If The else statement Nested If Example: LetterCheck.java

3 &&, &, ||, |, ! They are working upon logical expressions to produce true/false What is the difference between &&, & (short cutting) The standard Library character manipulation classes (Character.isUpperCase(), etc.) Logical Operators

4 It has the following form and always returns a value of one of the two exps. Logical exp? exp1:exp2; Example: ConditionalOp.java The switch statement can perform multiple selections. Using the break statement Local variables are visible only in limited scope Example: Scope.java Conditional Operator and switch

5 Different types (for, while, do—while) Initialization, test, & increment conditions Loop counters can be int or float Nested loops, example Factorial.java Break, continue, labeled break and continue Assertion: “assert logical-exp;” Compile with “-source 1.4” and run with “-ea”, example TryAssertions.java Loops