ARITHMETIC
OPERATORS
ARITHMETIC OPERATORS
Arithmetic operators are used to
compute the numerical value of
variables.
ARITHMETIC OPERATORS
Operator Description
+ Adds two operands
- Subtracts second operand from the first
* Multiplies both operands
/ Divides one operand by another and returns a floating point result
\ Divides one operand by another and returns an integer result.
^ Raises one operand to the power of another
Modulus Operator is used to get the remainder of two operands when
MOD or %
divided.
EXAMPLE: Addition
Given: a = 10 b = 3
Find: ans
Solution:
ans = a + b;
Answer:
13 = 10 + 3
EXAMPLE: Subtraction
Given: a = 10 b = 3
Find: ans
Solution:
ans = a – b;
Answer:
7 = 10 - 3
EXAMPLE: Multiplication
Given: a = 10 b = 3
Find: ans
Solution:
ans = a * b;
Answer:
30 = 10 * 3
EXAMPLE: Division (Float)
Given: a = 10 b = 3
Find: ans
Solution:
ans = a / b;
Answer:
3.5 = 10 / 3
EXAMPLE: Division (Integer)
Given: a = 10 b = 3
Find: ans
Solution:
ans = b \ a;
Answer:
3 = 3 \ 10
EXAMPLE: Modulus
Given: a = 10 b = 3
Find: ans
Solution:
ans = a % b;
3 r.1 = a % b
Answer:
1 = 3 MOD 10
REFERENCES
iBook Development Group. (2015). Visual Basic Programming Essentials. Manila,
Philippines: iBook Publishing.
Tutorials Point. (2020). [Link] Programming Tutorial. Retrieved from
[Link]