Pps-2

1 of
Published on Video
Go to video
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Page 2 (8s)

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

Page 3 (16s)

. . What are these Looping Statements ?.

Page 4 (23s)

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

Page 5 (44s)

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

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

Page 7 (1m 12s)

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

Page 8 (1m 24s)

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

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

Page 10 (2m 19s)

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

Page 11 (2m 37s)

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

Page 12 (2m 55s)

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

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

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

Page 15 (4m 40s)

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

Page 16 (5m 0s)

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

Page 17 (5m 19s)

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

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

Page 19 (6m 18s)

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

Page 20 (6m 50s)

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

Page 21 (7m 12s)

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

Page 22 (7m 29s)

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

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

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

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

Page 26 (10m 16s)

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

Page 27 (10m 57s)

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