Pps-2

Published on Slideshow
Static slideshow
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Scene 2 (8s)

. . Looping Statements in C. ••ae«arueqs vueneqg nq.

Scene 3 (16s)

. . What are these Looping Statements ?.

Scene 4 (23s)

. . Looping Statements in C execute the sequence of statements many times until the stated condition becomes false..

Scene 5 (44s)

. . Types of loops in C : Entry controlled loops Exit controlled loops.

Scene 6 (55s)

. . ● In an entry control loop , a condition is checked before executing the body of a loop. It is also called as a pre-checking loop..

Scene 7 (1m 12s)

. . C programming language provides us with three types of loop constructs:..

Scene 8 (1m 24s)

. . . While Loop. A while loop is the most straightforward looping structure. While loop syntax in C programming language is as follows:.

Scene 9 (1m 49s)

. . It is an entry-controlled loop. In while loop, a condition is evaluated before processing a body of the loop. If a condition is true then and only then the body of a loop is executed. After the body of a loop is executed then control again goes back at the beginning, and the condition is checked if it is true. Once the condition becomes false, the control goes out of the loop..

Scene 10 (2m 19s)

. . 6 while(condition) 1 datio statements outside the loo.

Scene 11 (2m 37s)

. . Following program illustrates while loop in C programming :.

Scene 12 (2m 55s)

. . The whole process of the previous program can be interpreted according to the following script ( beginning in main) :.

Scene 13 (3m 37s)

. . Do-While loop A do...while loop in C is similar to the while loop except that the condition is always executed after the body of a loop. It is also called an exit-controlled loop..

Scene 14 (4m 9s)

. . In the do-while loop, the body of a loop is always executed at least once. After the body is executed, then it checks the condition. If the condition is true, then it will again execute the body of a loop otherwise control is transferred out of the loop..

Scene 15 (4m 40s)

. . ) true bod of the loo datio } while(condition); 6 statements outside the loo.

Scene 16 (5m 0s)

. . The following loop program illustrates the working of a do-while loop:.

Scene 17 (5m 19s)

. . The whole process of the previous program can be interpreted according to the following script ( beginning in main) :.

Scene 18 (5m 55s)

. . For Loop. A for loop is a more efficient loop structure in ‘C’ programming. It is an entry-controlled loop.The for loop is designed to iterate a number of times. Syntax of For Loop in C :.

Scene 19 (6m 18s)

. . The for loop provides specific locations to contain an initialization and an increase expression..

Scene 20 (6m 50s)

. . for ( initialisation; condition; //body of the loop datio ) 1 // Statements outside the loop.

Scene 21 (7m 12s)

. . Following program illustrates the for loop in C programming example :.

Scene 22 (7m 29s)

. . The whole process of the previous program can be interpreted according to the following script ( beginning in main) :.

Scene 23 (8m 10s)

. . In C, the for loop can have multiple expressions separated by commas in each part. For example : for (x=0,y=num; x<y; i++,y--) Also, we can skip the initial value expression, condition and/or increment by adding a semicolon. For example :.

Scene 24 (8m 39s)

. . Notice that loops can also be nested where there is an outer loop and an inner loop. For each iteration of the outer loop, the inner loop repeats its entire cycle..

Scene 25 (9m 14s)

. . Note :. The control conditions must be well defined and specified otherwise the loop will execute an infinite number of times. The loop that does not stop executing and processes the statements number of times is called as an infinite loop. An infinite loop is also called as an “Endless loop.” Following are some characteristics of an infinite loop : 1. No termination condition is specified. 2. The specified conditions never meet..

Scene 26 (10m 16s)

. . Jump statements :. Jump statements allow altering the flow of a program by performing jumps to specific locations..

Scene 27 (10m 57s)

. . References :. https://m.cplusplus.com/doc/tutorial/control/.