Do Loops Code Examples

This post continues with examples in multiple languages of various coding routines. It’s goal is to assist someone transitioning from one language to another.

In this example we cover the simple do loop.

PHP


$x = 0;
do{
  // Do Something
  $x++;
}
while($x <= 4);

C#


int x = 0;
do{
  // Do Something
  x++;
}
while(x <= 4);

VB .NET


Dim i = 0
Do Until i = 10
  ' Do Something
  i = i + 1
Loop

Objective C (iPhone)


int x = 0;
do{
     NSLog(@"x = %i", x);
     x++;
}
while(x <= 4);

Leave a Reply