Learning to Program with the Cybiko Handheld Computer Using B2C

Chapter 13 : Math Operations

B2C supports a host of math Operations.  The ordinary operations exist (+, -, *, /,MOD) with which you can do math calculations.  The Order of Operations applies (multiplication and division first, then addition and subtraction) and parentheses are used to change the order of operations. (a=(a+b)*c).

B2C currently supports only integer arithmetic.

dim a as int
a = 5 + 1
print "the answer is ", a
> the answer is 6

Random Numbers

Random numbers are numbers whose value is unpredictable.  You can get a random number with the Rnd() function:

Rnd(x)

Where 'x' is any number.  Rnd(x) will return a number from 0 to 'x' inclusive.

x=rnd(5)+1  'return a number from 1 to 6, like a 6-sided die