Web+ Tutorial

Previous

  Contents  

Next

Lesson 1.2 - Math Operators

By the end of this lesson, you will learn how to perform basic math operations using Web+.
Description
The following table lists the math operators available with Web+.
OperatorMeaning
+Addition
-Subtraction
*Multiplication
/Division
^Exponentiation
%Modulas

Syntax
#operand1 operator operand2#
Example
#grossPay - taxes#
#Result * 2.3 / FirstNum#
#(grade1 + grade2 + grade3) / 3#
#(hoursWorked * rate) - (hoursWorked * rate * taxRate)#
#num1 ^ num2#

Sample
<webSet #UnitPrice# = 128>
<webSet #Quantity# = 10>
<webSet #Total# = #UnitPrice * Quantity#>
<webPrint>If widgets cost $#UnitPrice# each, then
#Quantity# widgets will cost $#Total#.</webPrint>
Result:
Exercise
Now write a Web+ program to perform some basic mathematical operation such as (((1+2)*(3+4)/5)*6).

You can try out some Web+ code of your own here.

Previous

  Contents  

Next

 

Copyright © 2009 Webplus, Inc. (talentsoft). All Rights Reserved.
webmaster@webplus.com