If-Statements and If/Else Statements

Slides:



Advertisements
Similar presentations
Selection Statements Make a decision based on conditions Allows the computer to be intelligent.
Advertisements

CS0007: Introduction to Computer Programming
Control Structures Control structures are used to manage the order in which statements in computer programs will be executed Three different approaches.
Conditional Statements and Loops. Today’s Learning Goals … Learn about conditional statements and their structure Learn about loops and their structure.
Loops For While Do While. Loops Used to repeat something Loop statement creates and controls the loop.
1 Pseudocode For Program Design. 22 Rules for Pseudocode Write only one statement per line Capitalise initial keyword Indent to show hierarchy and structures.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Conditional Statements Control Structures.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Logical and Relational Expressions Nested if statements.
New Mexico Computer Science For All More Looping in NetLogo Maureen Psaila-Dombrowski.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
Programming With Alice. Alice Free Java based, 3D programming tool Enables the manipulation and interaction of 3D objects Can also.
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.
HOMEWORK REVIEW This is an if else statement layout if (condition) { code to be executed if condition is true; } else { code to be executed if condition.
Bell Ringer = – 5 = = ÷ -2 = =6. -7 – (-7) = After you have completed the bell ringer, take out your homework!
Order of Operations Topic
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
CPS120 Introduction to Computer Programming The Programming Process.
© Jalal Kawash Programming Peeking into Computer Science 1.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
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.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Repetition. Loops Allows the same set of instructions to be used over and over again Starts with the keyword loop and ends with end loop. This will create.
ITK 168 Decisions Dr. Doug Twitchell September 20, 2005.
Chapter 4 October 22, The If Statement Programs make decisions If(condition){ Statement(s); } Condition  boolean expression Evaluates to either.
Lesson thirteen Conditional Statement "if- else" ©
Decision Making: while loops and Boolean Logic. While Loops A while loop is a structure within ROBOTC which allows a section of code to be repeated as.
Sensor Information: while loops and Boolean Logic.
Computer Science 1000 LOGO II. Boolean Expressions like Excel and Scratch, LOGO supports three Boolean operators less than (
FOP: While Loops.
CHAPTER 4 DECISIONS & LOOPS
COMP 14 Introduction to Programming
Chapter 3: Decisions and Loops
OBJECT ORIENTED PROGRAMMING I LECTURE 8 GEORGE KOUTSOGIANNAKIS
Sequence, Selection, Iteration The IF Statement
The switch Statement, and Introduction to Looping
Chapter 4: Control Structures
Simple Control Structures
Programming Fundamentals
Chapter 6: Conditional Statements and Loops
Expressions and Control Flow in JavaScript
JavaScript.
The final zeroes are not significant, they don’t have an impact on the size of the number. So these numbers are equal. They have the same value – 4/10.
CPS120: Introduction to Computer Science
CMSC 120: Visualizing Information 3/25/08
IF if (condition) { Process… }
Computers & Programming Languages
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Coding Concepts (Sub- Programs)
Control Structures: Selection Statement
BODMAS explained Joshua and Mohammed Thank you Introduce each other.
Design and Implementation
Logical Operations In Matlab.
Computer Science Core Concepts
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
An Introduction to Linux
Order of Operations PEMDAS.
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.
Angles on a straight line Vertically opposite angles
Control Structures: Selection Statement
Decision making and control functions
Millennium High School Agenda Calendar
ORDER OF OPERATIONS.
Factors, multiple, primes: Multiples
How to allow the program to know when to stop a loop.
Presentation transcript:

If-Statements and If/Else Statements Using Conditionals to make decisions

REVIEW OF LOOPS! What is the best way for Karel to move 10 times? move(); move(); move(); move(); move(); move(); move(); move(); move(); move(); B. for (var i = 0; i < 10; i++) { move(); } C. move(10); D. move10();

What does this For loop mean? for (var i = 0; i < 10; i++) { move(); } “Var i” refers to everything inside the curly brackets, so when it says “i <10; I++” it is actually saying that it will call “var i”, add one number to it, and then follow the loop again UNTIL it is equal to or greater than 10.

When to use If-Statements If statements have a specific purpose, just like functions and loops. Statements help the computer prevent errors by calculating a decision based on the rules it has created. When would we use something called an “If/Else-Statement”?

If/Else Statements If/Else statements are used when you need the computer to make more complex responses to decisions, meaning that it is dealing with multiple true or false problems