LOOPING STRUCTURE Chapter - 7 Padasalai

Slides:



Advertisements
Similar presentations
Looping Structures: Do Loops
Advertisements

CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
CHAPTER 5: LOOP STRUCTURES Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Creating PHP Pages Chapter 7 PHP Decisions Making.
Objectives Using functions to organize PHP code
PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
ITC 240: Web Application Programming
Chapter 4 Functions and Control Structures PHP Programming with MySQL.
Week 11 Recap CSE 115 Spring Want to write a programming language? You’ll need three things: You’ll need three things: –Sequencing –Selection Polymorphism.
The foreach LooptMyn1 The foreach Loop The foreach loop gives an easy way to iterate over arrays. foreach works only on arrays, and will issue an error.
Decisions, Loops, and Arrays Achmad Arwan, S.Kom.
Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 2: Major Concepts of Programming.
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.
Chapter 5 Control Structures: Loops 5.1 The while Loop The while loop is probably the most frequently used loop construct. The while loop is a conditional.
CPS120 Introduction to Computer Science Iteration (Looping)
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.
Control Structures By Shyam Gurram. Control Structure In this chapter we have two different types of structures. Conditional Structure Iterative Control.
Chapter 7 LOOPING OPERATIONS: ITERATION. Chapter 7 The Flow of the while Loop.
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,
PHP Constructs Advance Database Management Systems Lab no.3.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Chapter 5: Control Structures: Iteration Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
CPS120 Introduction to Computer Science Iteration (Looping)
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
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.
Chapter 7: Repetition Structure (Loop) Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills.
IST 210: PHP LOGIC IST 210: Organization of Data IST210 1.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
LOOPS CHAPTER Topics  Four Types of Loops –while –do…while –for –foreach  Jump Statements in Loops –break –continue 2.
Learning Javascript From Mr Saem
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.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
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 this.
PHP using MySQL Database for Web Development (part II)
Expressions and Control Flow in PHP
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Chapter 5: Repetition Structures
Scripts & Functions Scripts and functions are contained in .m-files
CiS 260: App Dev I Chapter 4: Control Structures II.
Web Programming– UFCFB Lecture 16
ITM 352 Flow-Control: Loops
Chapter 5 Structures.
While Loops BIS1523 – Lecture 12.
Chapter 6 Repetition Objectives ❏ To understand basic loop concepts:
Arrays, For loop While loop Do while loop
Loop Control Structure.
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
Control Structures: for & while Loops
Repetition Control Structure
LabVIEW.
Objectives In this chapter, you will:
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
ICT Programming Lesson 3:
Decisions, Loops, and Arrays
CHAPTER 21 LOOPS 1.
Introduction to Computer Science
PROGRAM FLOWCHART Iteration Statements.
PHP an introduction.
PHP Function and Array 05 CHAPTER Padasalai MOHAMED FAKRUDEEN
PHP CONDITIONAL STATEMENTS
JavaScript 101 Lesson 8: Loops.
Presentation transcript:

LOOPING STRUCTURE Chapter - 7 Padasalai MOHAMED FAKRUDEEN, PGT-COMPUTER SCIENCE SHAMROCK MATRIC. HR. SEC. SCHOOL, MOGAPPAIR, CHENNAI-107

Learning objectives To understand the importance of looping structure. To know different types of looping structure in PHP. To know the basic fundamental logic creation using looping structure.

Looping structure Looping structure are useful for writing iteration logics. It is most feature of many programming languages , including PHP.

Categories of “loop” They are implemented using the following categories. for loop While loop for each loop Do while loop

For loop: For loop is an important functional looping system which is used for iteration logics when the programmer know in advance how many times the loop should run.

SYNTAX for( init counter; test counter; increment counter) { code to be executed; }

PARAMETERS init counter: Initialize the loop initial value. Test counter: Evaluated for every iteration of the loop. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends. Increment counter: Increases the loop counter value.

EXAMPLE <?php for( $i = 0; $i<= 10; $i++) { echo “ The numbers is: $i<br>”; } ?>

For loop Structure and Flow chart

Foreach loop: Foreach loop is exclusively available in PHP. It works only with arrays. The loop iteration deepens on on each KEY value pair In the array. For each,loop iteration the value of the current array element is assigned to $ value variable and the array pointer is shifted by one, until it reaches the end of the array element.

Foreach loop Structure and Flow

SYNTAX: foreach ($array as $value) { code to be executed; }

EXAMPLE: <?php $Student_name=array (“Magilan”, “Iniyan”, “Nilani”, “Sibi”, “Shini”) ; foreach ($Student _name as $value) { echo “ $value <br>” ; } ?>

While loop: While loop is an important feature which is used for simple iteration logics. It is checking the condition whether true or false. It executes the loop if specified condition is true. Refer figure 7.4.

While loop Structure and Flow

SYNTAX: while ( condition is true) { code to be executed; }

EXAMPLE: <?php $Student_count = 10; $Student_number = 1; while ($Student_number <=$Student _count) { echo “ The student number is: $Student_number <br>” ; $Student_number ++ ; } ?>

Do while loop: Do while loop always run the statement inside of the loop block at the first time execution. Then it is checking the condition whether true or false. It executes the loop if specified condition is true . Refer figure 7.4.

SYNTAX: do { code to be executed; } while (condition

DoWhile loop Structure and Flow Chart

EXAMPLE <?php $Student_count = 10; $Student_number = 1; do { echo “ The student number is: $Student_number <br>” ; $Student_number ++ ; } while ( $Student_number <= $Student_count) ?>

Points to remember PHP while loops execute a block of code while the specified condition is true. The for loop is used when you know in advance how many times the script should run. The foreach loop works only on arrays, and is used to loop through each key/value pair in an array. do...while - loops through a block of code once, and then repeats the loop as long as the specified condition is true

Next topic Forms and Files