#6 Loops in C Programming Language | CBSE | Online Tutorial | Free | Class8 #ProgrammingWithNI3 #Variable #C #Programming #Language #ComputerProgrammingLanguage #ProgrammingLanguage #Computer #Input #Output #Command #Code #TurboC #Download #Statement #forloop #whileloop #dowhileloop #cbse #Class8 #ClassVIII
#6 Loops in C Programming Language | CBSE | Online Tutorial | Free | Class8
#ProgrammingWithNI3 #Variable #C #Programming #Language #ComputerProgrammingLanguage #ProgrammingLanguage #Computer #Input #Output #Command #Code #TurboC #Download #Statement #forloop #whileloop #dowhileloop #cbse #Class8 #ClassVIII
What are Loops?
A Loop executes the sequence of statements many times until the stated condition becomes false. A loop consists of two parts, a body of a loop and a control statement. The control statement is a combination of some conditions that direct the body of the loop to execute until the specified condition becomes false. The purpose of the loop is to repeat the same code a number of times.
In this tutorial, you will learn-
Types of Loops
While Loop
Do-While loop
For loop
Which loop to Select?
Types of Loops
Depending upon the position of a control statement in a program, a loop is classified into two types:
1. Entry controlled loop
2. Exit controlled loop
In an entry controlled loop, a condition is checked before executing the body of a loop. It is also called as a pre-checking loop.
In an exit controlled loop, a condition is checked after executing the body of a loop. It is also called as a post-checking loop.
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.
The specified condition determines whether to execute the loop body or not. 'C' programming language provides us with three types of loop constructs:
1. The while loop
2. The do-while loop
3. The for loop
Which loop to Select?
Selection of a loop is always a tough task for a programmer, to select a loop do the following steps:
Analyze the problem and check whether it requires a pre-test or a post-test loop.
If pre-test is required, use a while or for a loop.
If post-test is required, use a do-while loop.
Summary
Looping is one of the key concepts on any programming language.
It executes a block of statements number of times until the condition becomes false.
Loops are of 2 types: entry-controlled and exit-controlled.
'C' programming provides us 1) while 2) do-while and 3) for loop.
For and while loop is entry-controlled loops.
Do-while is an exit-controlled loop.
----------------------------------- SUPPORT ME BY (ITS FREE) --------------------------------------
LIKE | COMMENT | SHARE | SUBSCRIBE | PRESS BELL ICON FOR NEW VIDEOS
Comments
Post a Comment