Presentation is loading. Please wait.

Presentation is loading. Please wait.

Loop Control Structure.

Similar presentations


Presentation on theme: "Loop Control Structure."— Presentation transcript:

1 Loop Control Structure.
Presented By: Sallar Khan

2 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

3 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.

4 ..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.

5 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.

6 ..For Loop (Example) OUTPUT

7 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.

8 ..While Loop(Cont.) Flow Diagram

9 ..While Loop (Example) OUTPUT

10 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.

11 ..Do While Loop (Example)
OUTPUT

12 Thank You!


Download ppt "Loop Control Structure."

Similar presentations


Ads by Google