+ 2
What is Pretest loop? Can you give example
pretest loop
5 odpowiedzi
+ 6
Pretest loop runs zero(0) or more times.
while (condition)
{
/* ... */
}
Post test loop runs one(1) or more times but at least once.
do {
/* ... */
while (condition);
+ 1
The pretest loop checks the condition and, if true, executes the statements in its body.
For example
i=0;
while (i<3) {
Console.WriteLine(i);
i++;
}
This will output
1
1
1
but next code:
i=4;
while (i<3) {
Console.WriteLine(i);
i++;
}
has no any outputs.
+ 1
Thanks!!
0
Pretest and posttest loops examples
0