Loop Control Structure.

Slides:



Advertisements
Similar presentations
Java Control Statements
Advertisements

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.
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Executes a statement or statements for a number of times – iteration. Syntax for(initialize; test; increment) { // statements to be executed } Initial.
June 10, 2015ICS102: while & do-while1 while and do-while Statements.
1 10/20/08CS150 Introduction to Computer Science 1 do/while and Nested Loops Section 5.5 & 5.11.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
Switch structure Switch structure selects one from several alternatives depending on the value of the controlling expression. The controlling expression.
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
Computer Programming 1 Repetition. Computer Programming 2 Objectives Repetition structures Study while and do loops Examine for loops A practical example.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
Flow of Control Loops – Chapter 3.2. Java Loop Statements: Outline the while Statement the do-while Statement the for Statement.
 Decision making statements Decision making statements if statement if...else statement Nested if...else statement (if...elseif....else Statement) 
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.
Lecture 8: Choosing the Correct Loop. do … while Repetition Statement Similar to the while statement Condition for repetition only tested after the body.
Chapter 7 LOOPING OPERATIONS: ITERATION. Chapter 7 The Flow of the while Loop.
Chapter 7 Additional Control Structures. 2 2 void GetYesOrNo (/* out */ char& response) // Inputs a character from the user // Postcondition: response.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
LOGO Conditional Statements & Loops in JavaScript CHAPTER 10 Eastern Mediterranean University School of Computing and Technology Department of Information.
L OO P S While writing a program, there may be a situation when you need to perform some action over and over again. In such situation you would need.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 5: Introduction to C: More Control Flow.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
CSC 107 – Programming For Science. Today’s Goal  Know how to use and write for loops  Explain why to use for, while, & do-while loops  Convert between.
REPETITION STATEMENTS - Part1  Also called LOOP STATEMENTS OR LOOP STRUCTURES 1 C++ Statements that repeat one or more actions while some condition is.
COMP Loop Statements Yi Hong May 21, 2015.
Chapter 7: Repetition Structure (Loop) Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills.
Programming Language C++ Lecture 3. Control Structures  C++ provides control structures that serve to specify what has to be done to perform our program.
CPSC 233 Tutorial 5 February 2 th /3 th, Java Loop Statements A portion of a program that repeats a statement or a group of statements is called.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
LOOPS IN ‘C’ PROGRAMMING. V ERY O FTEN, Y OU W ILL W ANT TO D O S OMETHING M ORE T HAN O NCE HA.
Loop Control อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 8.
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
Chapter 7 Control Structures. Java has very flexible three looping mechanisms. You can use one of the following three loops:  while Loop  do...while.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
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.
LESSON 5 Loop Control Structure. Loop Control Structure  Operation made over and over again.  Iterate statement.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 10P. 1Winter Quarter Repetition Structures Lecture 10.
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
Chapter 6: Loops.
Chapter 4 Repetition Statements (loops)
Unit-1 Introduction to Java
Control Structures.
Chapter 5: Repetition Structures
CiS 260: App Dev I Chapter 4: Control Structures II.
Programming Fundamentals
Expressions and Control Flow in JavaScript
JavaScript: Control Statements.
Chapter 5 Structures.
CS149D Elements of Computer Science
MSIS 655 Advanced Business Applications Programming
IF if (condition) { Process… }
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
Loops in C.
for, do-while and switch statments
Three Special Structures – Case, Do While, and Do Until
Lab5 PROGRAMMING 1 Loop chapter4.
Conditional Statements & Loops in JavaScript
A LESSON IN LOOPING What is a loop?
JavaScript: Control Statements II
PROGRAM FLOWCHART Iteration Statements.
Decision making and control functions
Repetition Structures
Chapter 8 JavaScript: Control Statements, Part 2
Presentation transcript:

Loop Control Structure. Presented By: Sallar Khan

Contents What is Loop ? For Loop While Loop Do While Loop Breaking out of Loop Continue to the next Loop Loop with Conditional Statement Switch Statement

What is Loop ? When a block of code needs to be executed several number of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on.

..Loop (Cont.) A loop statement allows us to execute a statement or group of statements multiple times. Given figure is the general form of a loop statement in most of the programming languages.

For Loop A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.

..For Loop (Example) OUTPUT

While Loop The while loop checks whether the  test expression is true or not. If it is true, code/s inside the body of while loop is executed, that is, code/s inside the braces { } are executed.  Then again the test expression is checked whether test expression is true or not. This process continues until the test expression becomes false.

..While Loop(Cont.) Flow Diagram

..While Loop (Example) OUTPUT

Do While Loop In C, do...while loop is very similar to while loop. Only difference between these two loops is that, in while loops, test expression is checked at first but, in do...while loop code is executed at first then the condition is checked. So, the code are executed at least once in do...while loops.

..Do While Loop (Example) OUTPUT

Thank You!