Difference between revisions of "While"

From Mesham
Jump to navigationJump to search
m
Line 9: Line 9:
 
== Examples ==
 
== Examples ==
  
  var a:=10;
+
  function void main() {
while (a > 0) {
+
    var a:=10;
    a--;
+
    while (a > 0) {
 +
      a--;
 +
    };
 
  };
 
  };
  

Revision as of 14:12, 15 April 2013

Syntax

while (condition) whilebody;

Semantics

Will loop whilst the condition holds.

Examples

function void main() {
   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).

Since: Version 0.41b