This document discusses the Do...Loop statement in Visual Basic, which allows executing a block of code an indefinite number of times until a condition is met. There are two main variations: the Do While loop, which tests the condition before executing the code block, and the Do Loop While loop, which executes the code block first and then tests the condition. Examples are provided to illustrate each using a loop that adds values to a sum variable until it reaches a threshold. Key terms like Do, While, Until, and Loop are also defined.
The objective of the Level 5 Diploma in Information Technology is to provide learners with an excellent foundation for a career in a range of organisations. It designed to ensure that each learner is ‘business ready’: a confident, independent thinker with a detailed knowledge of Information Technology, and equipped with the skills to adapt rapidly to change.
#loops, #c, #program, #loops in c, #c loops, #loops introduction, #while and do while loop, #for loop in c programming, #loops in c programming, #c programming loop, #c loop programs, #looping structure in c, #looping
in this presentation i will explain you about Statements & block, If Else, ElseI f, Switch, While Loop, For loop, Do while loop, Break & continue in c++
A while loop in C programming
repeatedly executes a target
statement as long as a given
condition is true.
A while loop in C programming
repeatedly executes a target
statement as long as a given
condition is true.
C for Loop
Loops are used in programming to execute a block of code repeatedly until a specified condition is met. In this tutorial, you will learn to create for loop in C programming.
C programming has three types of loops:
for loop
while loop
do...while loop
what are loop in general
what is loop in c language
uses of loop in c language
types of loop in c language
program of loop in c language
syantax of loop in c language
The objective of the Level 5 Diploma in Information Technology is to provide learners with an excellent foundation for a career in a range of organisations. It designed to ensure that each learner is ‘business ready’: a confident, independent thinker with a detailed knowledge of Information Technology, and equipped with the skills to adapt rapidly to change.
#loops, #c, #program, #loops in c, #c loops, #loops introduction, #while and do while loop, #for loop in c programming, #loops in c programming, #c programming loop, #c loop programs, #looping structure in c, #looping
in this presentation i will explain you about Statements & block, If Else, ElseI f, Switch, While Loop, For loop, Do while loop, Break & continue in c++
A while loop in C programming
repeatedly executes a target
statement as long as a given
condition is true.
A while loop in C programming
repeatedly executes a target
statement as long as a given
condition is true.
C for Loop
Loops are used in programming to execute a block of code repeatedly until a specified condition is met. In this tutorial, you will learn to create for loop in C programming.
C programming has three types of loops:
for loop
while loop
do...while loop
what are loop in general
what is loop in c language
uses of loop in c language
types of loop in c language
program of loop in c language
syantax of loop in c language
2. USE Use a Do…Loop to execute a block of statements an indefinite number
of times. There are several variations of the Do...Loop statement, but
each evaluates a numeric condition to determine whether to continue
execution. As with If...Then, the condition must be a value or expression
that evaluates to False (zero) or to True (nonzero).
Do…Loop
}
3. In the following Do...Loop, the statements execute as
long as the condition is True:
Do While condition
statements
Loop
When Visual Basic executes this Do…Loop, it first tests condition. If condition is False (zero), it skips
past all the statements. If it's True (nonzero), Visual Basic executes the statements and then goes
back to the Do…While statement and tests the condition again.
Example :
Dim sum As Integer = 0
Dim counter As Integer = 0
Do While sum < 100
sum = sum + CInt(Textbox1.Text)
counter = counter + 1
Loop
MsgBox("The loop has run " & CStr(counter) & " times!")
4. Another variation of the Do...Loop statement executes the statements first
and then tests condition after each execution. This variation guarantees at
least one execution of statements:
Do
statements
Loop While condition
Example :
Dim sum As Integer = 0
Dim counter As Integer = 0
Do sum = sum + CInt(Textbox1.Text)
counter = counter + 1
Loop While sum < 100
MsgBox("The loop has run " & CStr(counter) & " times!")
5. Term Definition
Do Starts the definition of the Do loop.
While Repeat the loop until condition is False.
Until Repeat the loop until condition is True.
condition Boolean expression. If condition is Nothing, Visual Basic treats it as False.
statements One or more statements that are repeated while, or until, condition is True.
Continue Do Transfers control to the next iteration of the Do loop.
Exit Do Transfers control out of the Do loop.
Loop Terminates the definition of the Do loop.
You can use either While or Until to specify condition, but not both.
6. * The above example will keep on adding until counter > 1000.
The above example can be rewritten as :
Do
while counter <= 1000
num.Text = counter
counter = counter + 1
Loop
Example :
Do
num.Text = counter
counter = counter + 1
Loop Until counter > 1000