Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
PRESANTATION ON
“Looping control structure”
GUPTA HARSH
13ME030
Introduction of loop
• A loop is a programming structure that allows
an action to repeat until the program meets a
given c...
CONTINUE…
• Loop: a control structure that repeats a group
of steps in a program
• C loop control statements
• Two types o...
Exit Control loop
• In exit control loop, the
body is executed first and
then the condition is
checked.
• In exit control ...
Entry Control loop
• In entry control loop,
the condition is checked
first and then body is
executed.
• In Entry control l...
Looping…
• ‘C’ language provides following looping
structures:-
1. WHILE
2. DO-WHILE
3. FOR
WHILE LOOP
– Of the three different loop structures offered in C, while-
loops are conceptually the simplest.
– Resembles ...
DO-WHILE LOOP
– The second type of loop offered in C is the do-while.
– Clearly the least commonly used of the three: one ...
FOR LOOP
– The third type of loop structure in C is suitable for
the common task of iterating through the values of
a rang...
CONTINUE…
– It is not a coincidence that the header of a for-loop
consists of three parts, for the three things that
defin...
Flowchart of FOR LOOP
for( initializing list;condition; updation)
BREAK STATEMENT
• Remember the break keyword that we used
to stop a switch statement from executing
more than one statemen...
CONTINUE STATEMENT
– Continue is a statement similar to break, but
instead of jumping out of the loop altogether, it
jumps...
Introduction to loops  cpu
Introduction to loops  cpu
Introduction to loops  cpu
Próxima SlideShare
Cargando en…5
×

Introduction to loops cpu

Looping Control Structure.

  • Inicia sesión para ver los comentarios

Introduction to loops cpu

  1. 1. PRESANTATION ON “Looping control structure” GUPTA HARSH 13ME030
  2. 2. Introduction of loop • A loop is a programming structure that allows an action to repeat until the program meets a given condition. • After each iteration of a loop, the loop checks against a loop control expression to see if the program met a the given condition. If it did, the loop stops. If not, the loop moves on to the next iteration.
  3. 3. CONTINUE… • Loop: a control structure that repeats a group of steps in a program • C loop control statements • Two types of control statement….. They are:- Exit control loop and Entry control loop
  4. 4. Exit Control loop • In exit control loop, the body is executed first and then the condition is checked. • In exit control loop the body is executed at least once.
  5. 5. Entry Control loop • In entry control loop, the condition is checked first and then body is executed. • In Entry control loop the body is not executed at all if the condition is false.
  6. 6. Looping… • ‘C’ language provides following looping structures:- 1. WHILE 2. DO-WHILE 3. FOR
  7. 7. WHILE LOOP – Of the three different loop structures offered in C, while- loops are conceptually the simplest. – Resembles if-statement, but does not have an else. – Conceptually, keep executing the loop body again and again till the condition is true. – Loop terminates when the loop condition becomes false. – Note that the truth of the loop condition is not checked constantly between every statement in the loop body, but only at the beginning of the loop, and then again between the repetitions of the loop body – Condition may be temporarily false during the loop, but become true again before it is checked
  8. 8. DO-WHILE LOOP – The second type of loop offered in C is the do-while. – Clearly the least commonly used of the three: one famous study of real world programs revealed that out of all loops in them, only 1% are do-while. – Do-while behaves exactly the same way as the while-loop, but is guaranteed to execute its body at least once before it starts looking at the loop condition. – The possibility of executing the loop body zero times does not exist, even if the condition is initially false – do-while is most useful in situations where testing the condition simply does not make any sense until the loop body has been executed once
  9. 9. FOR LOOP – The third type of loop structure in C is suitable for the common task of iterating through the values of a range of integers, one value at the time. – For example, go through the numbers from 1 to 100. – The for-loop header defines this range, and the loop body contains the statements you execute for each value. – To define an integer range, you need to define three things: where it begins (1), where it ends (100), and the step size between the consecutive values of the range (1)
  10. 10. CONTINUE… – It is not a coincidence that the header of a for-loop consists of three parts, for the three things that define a range. – We can still use while like in countdown, but using a for-loop makes it clear that we are going through a range. – It is not a coincidence that the header of a for-loop consists of three parts, for the three things that define a range. – We can still use while like in countdown, but using a for-loop makes it clear that we are going through a range.
  11. 11. Flowchart of FOR LOOP for( initializing list;condition; updation)
  12. 12. BREAK STATEMENT • Remember the break keyword that we used to stop a switch statement from executing more than one statement? • break can also be used to exit an infinite loop • But it is almost always best to use a well- written while loop.
  13. 13. CONTINUE STATEMENT – Continue is a statement similar to break, but instead of jumping out of the loop altogether, it jumps to the next round of the loop, skipping the rest of the body – Most commonly used to skip some of the values inside the range for which the loop doesn't need to do anything

×