Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.

Slides:



Advertisements
Similar presentations
Selection Feature of C: Decision making statements: It allow us to take decisions as to which code is to be executed next. Since these statements control.
Advertisements

Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Decision Making with Control Structures and Statements (non-audio version) © Dr. David.
1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
Creating PHP Pages Chapter 7 PHP Decisions Making.
1 CS101 Introduction to Computing Lecture 23 Flow Control & Loops (Web Development Lecture 8)
PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
1 Lecture 8:Control Structures I (Selection) (cont.) Introduction to Computer Science Spring 2006.
Selection Statements choice of one among several blocks of code Java supports 3 kinds of selection statements: if statement – selects one block or leaves.
true (any other value but zero) false (zero) expression Statement 2
Chapter 4 Functions and Control Structures PHP Programming with MySQL.
Conditional Statements While writing a program, there may be a situation when you need to adopt one path out of the given two paths. So you need to make.
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.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
Object-Oriented Programming Using C++ Third Edition Chapter 3 Making Decisions.
Visual C# 2005 Decision Structures. Visual C# Objectives Understand decision making Learn how to make decisions using the if statement Learn how.
1 CSC103: Introduction to Computer and Programming Lecture No 11.
CPS120: Introduction to Computer Science Decision Making in Programs.
Chapter 4: Making Decisions. Understanding Logic-Planning Tools and Decision Making Pseudocode – A tool that helps programmers plan a program’s logic.
CONTROL STRUCTURE The if, elseif, and else & switch Statements 1.
Flow of Control Part 1: Selection
Simple Control Structures IF, IF-ELSE statements in C.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
Chapter 3. Outline Relational Operators Loops Decisions Logical Operators Precedence Summary.
Conditional Statement Chapter 8. Conditional Statements Are statements that check an expression then may or may not execute a statement or group of statement.
Decision making statements. Decision making statements are used to skip or to execute a group of statements based on the result of some condition. The.
1 2. Program Construction in Java. 2.4 Selection (decisions)
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
4.1 Object Operations operators Dot (. ) and new operate on objects The assignment operator ( = ) Arithmetic operators + - * / % Unary operators.
CSE 425: Control Flow I Categories of Control Flow Constructs Sequencing –order of expressions and statements Selection –if, else, switch Iteration –loops.
JavaScript, Fourth Edition
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Conditional Statements © Copyright 2014, Fred McClurg All Rights Reserved.
Chapter 4 Control Structures I. Chapter Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate.
Working with Loops, Conditional Statements, and Arrays.
CPS120: Introduction to Computer Science Decision Making in Programs.
1 CS428 Web Engineering Lecture 13 Flow Control & Loops (JavaScript - III)
CPS120: Introduction to Computer Science Decision Making in Programs.
Chapter 2: Fundamental Programming Structures in Java Adapted from MIT AITI Slides Control Structures.
USING CONDITIONAL CODE AMIR KHANZADA. Conditional Statement  Conditional statements are the set of commands used to perform different actions based on.
JavaScript, Sixth Edition
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 2: Control Structures (Selection & Repetition)
Control Structure  What is control Structure?  Types of Controls  Use the control structure in VBScript.  Example Summery.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Silberschatz and Galvin  C Programming Language Decision making in C Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
If/Else Statements.
Decision Making in C.
Decisions Chapter 4.
Expressions and Control Flow in JavaScript
JavaScript: Control Statements.
Struktur Control : Decision
Control Structures.
Selection CSCE 121 J. Michael Moore.
Control Structures: Selection Statement
Professor Jodi Neely-Ritz CGS3460
CSC215 Lecture Flow Control.
CSC215 Lecture Control Flow.
Program Flow.
There many situations comes in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations.
Decisions, decisions, decisions
Control Structures: Selection Statement
CSC215 Lecture Control Flow.
Presentation transcript:

Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

Tutorial 4A Topics Section A - Decision Making if statements if…else statements Nested if statements switch statements JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

Decision Making Decision Making Process of determining the order in which statements execute in a program AKA – flow control Decision-Making Structures Special type of JavaScript statements used for making decisions JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

Decision Making if Statements Used to execute specific programming code if the evaluation of a conditional expression returns a value of true “Do this or don’t do this” Syntax (3 primary parts) if (conditional_expression) { statement(s); } JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

Decision Making if Statements Operation Command block If the conditional expression is true, the statement(s) is/are executed Control then continues to subsequent code Command block Multiple statements contained within a set of braces (require curly braces) JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

Decision Making if Statements Conditional Expression Can consist of: Comparison operators Logical operators Combination of the two Must resolve to Boolean value JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

Decision Making if…else Statements Used to execute one set of code if the evaluation of a conditional expression returns a value of true, otherwise executes another set of code “Do this or do something else” Syntax if (conditional_expression) { statement(s); } else { } JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

Decision Making Nested if and if…else Statements Nested statements Statements contained within other statements Syntax (variable) if (conditional_expression) { statement(s); } } else { JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

Decision Making switch Statements Controls program flow by executing a specific set of statements, depending on the value of an expression Syntax switch (expression) { case label1: statement(s); break; case label2: default: } JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

Decision Making switch Statements Case labels Break statement Identify specific code segments Can use a variety of data types as case labels Break statement Used to exit switch statements Default label Contains statements that execute when the condition expression doesn’t match any of the case labels JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

JavaScript Tutorial 4 -Decision Making with Control Structures and Statements

JavaScript Tutorial 4 -Decision Making with Control Structures and Statements