Skip to content
Snippets Groups Projects
Commit d5f7522a authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add while loops doc

parent e7863e89
No related branches found
No related tags found
1 merge request!145git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
......@@ -1975,9 +1975,35 @@ However, to ease the reading, it is probably better to write
It gives also
#+results: do-while-block
*** TODO while loops
*** ~while~ loops
The last kind of loops that is allowed in ~pugs~ language is the ~while~
loop.
#+BEGIN_SRC pugs :exports code
while (condition) statement
#+END_SRC
The ~statement~ is either a single instruction or a block of
instructions. The ~condition~ is an expression of boolean value (type
~B~).
This time is the ~condition~ is never satisfied (never ~true~), the
~statment~ is not executed.
An example of the ~while~ loop is the following.
#+NAME: while-block
#+BEGIN_SRC pugs :exports both :results output
let sum:N, sum = 0;
let i:N, i = 1;
while (sum<=10) {
sum += i;
++i;
}
cout << "sum = " << sum << "\n";
#+END_SRC
The result is
#+results: while-block
*** TODO break/continue
** TODO Functions<<functions>>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment