Nested if-else Statements.  Should be indented to make the logic clear.  Nested statement executed only when the branch it is in is executed. For example,

Slides:



Advertisements
Similar presentations
CS 240 Computer Programming 1
Advertisements

Chapter 10: The Traditional Approach to Design
Systems Analysis and Design in a Changing World, Fifth Edition
Lecture 3: Control Structures - Selection BJ Furman 10SEP2012.
More on Algorithms and Problem Solving
© 2007 Lawrenceville Press Slide 1 Chapter 5 The if Statement  Conditional control structure, also called a decision structure  Executes a set of statements.
ALGORITHMS AND FLOWCHARTS
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Selection Flow Charts If statements. Flow of Control The flow of control is a concept we’ve already encountered. The concept of control relates to the.
PSEUDOCODE & FLOW CHART
UNIT 2. Introduction to Computer Programming
Lesson 5 - Decision Structure By: Dan Lunney
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions.
Flow Chart.
Introduction to Programming Lecture 5. In the Previous Lecture Basic structure of C program Basic structure of C program Variables and Data types Variables.
ITEC113 Algorithms and Programming Techniques
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
Flowchart Diagram Risanuri Hidayat. What A Flow Chart is a sequential diagram that shows the steps involved in an operation or task and the decisions.
Introduction to Computers and Programming Lecture 5 New York University.
Introduction to Computers and Programming Lecture 5 Boolean type; if statement Professor: Evan Korth New York University.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Conditional Statements Control Structures.
Introduction to Computers and Programming Class 6 Introduction to C Professor Avi Rosenfeld.
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
Chapter 4: Control Structures: Selection
Flow Charts. Thinking Creatively Flow Charts START END Is A==6? No A = 1 Yes Print A A = A + 1.
Chapter 4 The If…Then Statement
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Structural Program Development: If, If-Else Outline.
Flowcharts! January 13, 2005 These are today’s notes! Do you think we will get more snow?
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
Simple Control Structures IF, IF-ELSE statements in C.
Lecture 2: Logical Problems with Choices. Problem Solving Before writing a program Have a thorough understanding of the problem Carefully plan an approach.
ITEC113 Algorithms and Programming Techniques
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Basic Control Structures
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Introduction to branching.
LO: We’re learning to demonstrate the need for breaking down problems into smaller ones.
Program Design BUILDING A HOUSE. Steps to Designing a Program 1. Define the Output 2. Develop the logic to get that output 3. Write the program.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
Week 8: Decisions Bryan Burlingame 21 October 2015.
1 Programming Tools Flowcharts Pseudocode Hierarchy Chart Direction of Numbered NYC Streets Algorithm Class Average Algorithm.
Selection Flow Charts If statements. Flow of Control The flow of control is a concept with which we’re already familiar. The concept of control relates.
CPS120: Introduction to Computer Science Decision Making in Programs.
Conditional Control Structures Chapter 5. Goals and Objectives Understand conditional control structures. Demonstrate the use of decision structures to.
These Guys? Wait, What? Really?  Branching is a fundamental part of programming  It means taking an action based on decision  The decision is dependent.
Learning Objective To be able to… Understand flow chart symbols Complete and correct flow chart algorithms Create a program based on a flow chart.
JAVA PROGRAMMING Control Flow. Jeroo: Finish Activities 1-7 Finish InputTest program w/changes.
Program design Program Design Process has 2 phases:
Chapter 5 The if Statement
Algorithm & Flow Charts Week 1
Flowchart Symbols Terminal Process Input/ Output Decision
ALGORITHMS CONDITIONAL BRANCH CONTROL STRUCTURE
Stage 7: Bee: Conditionals
Operator Precedence Operators Precedence Parentheses () unary
Flowcharting: Decision Structure
Numbering System TODAY AND TOMORROW 11th Edition
Programming Fundamentals
Activity Diagrams Activity diagrams describe the workflow behavior of a system.  The diagrams describe the state of activities by showing the sequence.
Lecture 2: Logical Problems with Choices
Introduction to Programming
Structured Program Design
Computers & Programming Languages
Structured Program
الفصل الثاني الخوارزمية
Practice with loops! What is the output of each function below?
Introduction to Algorithms and Programming
Program Flow.
Structural Program Development: If, If-Else
Presentation transcript:

Nested if-else Statements

 Should be indented to make the logic clear.  Nested statement executed only when the branch it is in is executed. For example, the statement if (x == 5) { y = 20; } else { if (x > 5) { y = 10; } else { y = 0; } } evaluates the nested if-else only when x is not equal to 5.

Flowchart Symbols decision statements of work

Flow Chart Basics Rectangles represent statements of work. For example: print() Diamonds (decision symbol) contain conditions flow line

Flow Chart Basics Sequence structure Connector symbol Triangle boxes represent statements such as x=30; int a; System.out.print(“x”); x=20;

Flowchart