Arithmetic Operators : VBScript



VBScript Arithmetic Operators :

Following is the list of Arithmetic Operators supported by VBScript. Consider that A = 20 and B = 10

Operator Description Example
+ Adds two operands A + B = 30
- Subtracts second operand from the first A – B = 10
* Multiply both operands A * B = 200
/ Divide numerator by denominator A / B = 2
% Modulus Operator and remainder of after division A MOD B = 0
^ Exponentiation Operator 10 ^ 2 = 100

Arithmetic Operator Example :

<!DOCTYPE html>
<html>
<body>
<script language="vbscript" type="text/vbscript">

   Dim num1 = 20
   Dim num2 = 10
   Dim res

   res = num1 + num2
   Document.write ("Addition Result :" &res)
   Document.write ("<br />")

   res = num1 - num2
   Document.write ("Subtraction Result :" &res)
   Document.write ("<br />")

   res = num1 * num2
   Document.write ("Multiplication Result :" &res)
   Document.write ("<br />")

   res = num2 / num1
   Document.write ("Division Result :" &res)
   Document.write ("<br />")

   res = num2 MOD num1
   Document.write ("Modulus Result :" &res)
   Document.write ("<br />")

   res = 10 ^ 2
   Document.write ("Exponentiation Result :" &res)
   Document.write ("<br />")
   
</script>
</body>
</html>

Output :

Addition Result : 30
Subtraction Result : 10
Multiplication Result : 200
Division Result : 2
Modulus Result : 0
Exponentiation Result : 100