statement. Another decision statement, , creates branches for multi-

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

Fundamental of C programming
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.
PHP Conditions MIS 3501, Fall 2014 Jeremy Shafer Department of MIS Fox School of Business Temple University September 11, 2014.
Introduction to Computers and Programming Lecture 9: For Loops New York University.
1 Parts of a Loop (reminder) Every loop will always contain three main elements: –Priming: initialize your variables. –Testing: test against some known.
Introduction to Computers and Programming for Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to.
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
Boolean Expressions and If Flow of Control / Conditional Statements The if Statement Logical Operators The else Clause Block statements Nested if statements.
Arrays, Conditionals & Loops in Java. Arrays in Java Arrays in Java, are a way to store collections of items into a single unit. The array has some number.
Section 3 - Selection and Repetition Constructs. Control Structures 1. Sequence 2. Selection 3. Repetition.
 Decision making statements Decision making statements if statement if...else statement Nested if...else statement (if...elseif....else Statement) 
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
Computer Science Department LOOPS. Computer Science Department Loops Loops Cause a section of your program to be repeated a certain number of times. The.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
CHAPTER 3 CONTROL STRUCTURES ( REPETITION ) I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Looping Construct or Statements. Introduction of looping constructs In looping,a sequence of statements are executed until some condition for termination.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
CPS120 Introduction to Computer Science Iteration (Looping)
Decision Making and Branching (cont.)
Programming Fundamentals. The setw Manipulator setw changes the field width of output. The setw manipulator causes the number (or string) that follows.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Loop Blocks Chapter 6 Part A. Program Blocks 1.Actions- commands, messages, methods 2.Branches- decisions to be made 3.Loops- actions to be repeated.
Python – Part 4 Conditionals and Recursion. Conditional execution If statement if x>0:# CONDITION print (‘x is positive’) Same structure as function definition.
Control Structure  What is control Structure?  Types of Controls  Use the control structure in VBScript.  Example Summery.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. 4 Simple Flow of Control.
Lecture 4b Repeating With Loops
Chapter 6: Loops.
Chapter 4 Repetition Statements (loops)
Chapter 3: Decisions and Loops
The switch Statement, and Introduction to Looping
Statements (6 of 6) A statement causes an action to be performed by the program. It translates directly into one or more executable computer instructions.
Boolean Expressions and If
The order in which statements are executed is called the flow of control. Most of the time, a running program starts at the first programming statement,
Programming Fundamentals
JavaScript: Control Statements.
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
Loop Control Structure.
Programming Fundamentals Lecture #6 Program Control
IF if (condition) { Process… }
Outline Altering flow of control Boolean expressions
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
In this class, we will cover:
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
3 Control Statements:.
CSC215 Lecture Flow Control.
CSC215 Lecture Control Flow.
Chapter 8: More on the Repetition Structure
Three Special Structures – Case, Do While, and Do Until
Visual Basic – Decision Statements
Selection Statements.
Summary Two basic concepts: variables and assignments Basic types:
Lab5 PROGRAMMING 1 Loop chapter4.
Computing Fundamentals
Lecture Notes – Week 2 Lecture-2
The for loop suggested reading:
A LESSON IN LOOPING What is a loop?
Lecture Notes – Week 2 Lecture-2
In this class, we will cover:
Repetition Statements (Loops) - 2
PROGRAM FLOWCHART Iteration Statements.
Using C++ Arithmetic Operators and Control Structures
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
CSC215 Lecture Control Flow.
Presentation transcript:

statement. Another decision statement, , creates branches for multi- Loops and Decisions Decisions can be made in C++ in several ways. The most important is with the statement, which chooses between two alternatives. This statement can be used without the , as a simple statement. Another decision statement, , creates branches for multi- ple alternative sections of code, depending on the value of a single variable. Finally, the condi- nstructions. The statement is the simplest of the decision statements. Our next program, IFDEMO, pro- vides an example. The keyword is followed by a test expression in parentheses. The syntax of the statement is very much like that of . The difference is that the statements following the are executed only once if the test expression is true; the statements following are executed repeatedly until the test expression the operation of the statement. IFDEMO ll terminate without printing the second line.

Syntax of the statement. Operation of the statement.

As in loops, the code in an Loops and Decisions As in loops, the code in an body can consist of a single statement as shown in the IFDEMO example or a block of statements delimited by braces. This variation on IFDEMO, called IF shows how that looks. IF nest s inside loops, loops inside s, s inside PRIME, that nests an within a loop. This example tells you whether a number you enter is a