Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

difference between while and do while in c#

//While statement
while ( condition) {
statements;  //body of loop
}
// do-while statement
do{
.
statements  // body of loop.
.
} while( Condition );
Comment

difference between while and do while in c#

Iteration statements allow the set of instructions to execute repeatedly till
the condition doesn’t turn out false.The Iteration statements in C++ and Java 
are, for loop, while loop and do while loop. These statements are commonly
called loops.Here, the main difference between a while loop and do while loop 
is that while loop check condition before iteration of the loop.On the other 
hand, the do-while loop verifies the condition after the execution of the 
statements inside the loop.Furthermore, the while loop is known as the 
entry-controlled loop.Conversely, the do while loop is called the exit 
controlled loop. In this article, we are going to discuss the differences 
between “while” loop and “do-while” loop.
Comment

difference between while and do while in c#

Key Differences Between while and do-while Loop
1.The while loop checks the condition at the starting of the loop and if the condition is satisfied statement inside the loop, is executed. As against, in the do-while loop, the condition is checked after the execution of all statements in the body of the loop.
2. If the condition in a while loop is false, not a single statement inside the loop is executed. In contrast, if the condition in ‘do-while’ loop is false, then also the body of the loop is executed at least once then the condition is tested.
3. The while loop is also known as the entry-controlled and pre-checking loop because in this loop, the body of the loop is executed prior to checking the condition. Conversely, the alternate name for the do-while loop is the exit-controlled and post-checking loop, the reason behind this is that the checking of the loop condition is followed by the execution of the body of the loop.
4. The syntax of a do-while loop includes a semi-colon to terminate the loop. On the contrary, there is no use of the semi-colon in the while loop syntax.
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# how many lines in methods 
Csharp :: create char array c# 
Csharp :: c# switch 
Csharp :: unity animator check if animation is playing 
Csharp :: unity how to load a scene 
Csharp :: C# How to write Hello World 
Csharp :: c# timer 
Csharp :: print array in c# 
Csharp :: get folders in directory c# 
Csharp :: how to find a gameobject in unity 
Csharp :: c# datagridview column size 
Csharp :: c# mailmessage set sender name 
Csharp :: button size xamarin 
Csharp :: c# base64 encode 
Csharp :: c# create array 
Csharp :: print content of array c# 
Csharp :: excel which style property define background color in c# 
Csharp :: header export excel data only php 
Csharp :: get current assembly path c# 
Csharp :: c# make request to rest api 
Csharp :: how to make unity build to not be full screen 
Csharp :: vb.net console log 
Csharp :: how to save datagridview data to database in c# windows application 
Csharp :: httpclient post c# example 
Csharp :: string to biginteger c# 
Csharp :: get char lowercase in c# 
Csharp :: contains char c# 
Csharp :: unity c# random number 
Csharp :: what is type unity 
Csharp :: find character from string c# count 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =