Declarations, control structures and statements that may be used in WL are restricted to:
Expressions may contain only variable names, integers (written in decimal without a sign) and the binary (two operand) versions of the following operators:
+ - * / % == != <= >= < >
The // notation (and only the // notation) may
be used for comments.
//
// WL Program to compute:
// a^b if 0 <= a,b < 10
// -1 otherwise
//
int wain(int a, int b) {
int counter = 0;
int product = 0;
product = 0-1; // only binary minus
if (a >= 0) {
if (b >= 0) {
if (a < 10) {
if (b < 10) {
product = 1;
counter = 0;
while (counter < b) {
product = product * a;
counter = counter + 1;
}
} else {} // must have else
} else {}
} else {}
} else {}
return product;
}