Difference between revisions of "While"

From Mesham
Jump to navigationJump to search
(Created page with '==Syntax== while (condition) whilebody; ==Semantics== Will loop whilst the condition holds. == Examples == var a:=10; while (a > 0) { a:=a - 1; }; Will loop, each t…')
 
Line 10: Line 10:
  
 
  var a:=10;
 
  var a:=10;
  while (a > 0)
+
  while (a > 0) {
{
+
     a--;
     a:=a - 1;
 
 
  };
 
  };
  

Revision as of 16:00, 12 January 2013

Syntax

while (condition) whilebody;

Semantics

Will loop whilst the condition holds.

Examples

var a:=10;
while (a > 0) {
   a--;
};

Will loop, each time decreasing the value of variable a by 1 until the value is too small (0)