Showing posts with label Arithmetic operations. Show all posts
Showing posts with label Arithmetic operations. Show all posts

Monday, June 6, 2011

Arithmetic operations

Arithmetic operations

Arithmetic operation is an operation involving arithmetic operators. Arithmetic Operators in Visual Basic is:
- plus (+)
- minus (-)
- times (*)
- for (/)
- rank (^)
- residual for (mod)

Arithmetic operators generally operate on two operands. For example the expression 2 + 2, means:
2 is the first operand
Arithmetic operator + is added
2 is the second operator.

But in some respects, especially operators + and less operate on one operand, such as giving the value of +5 (positive 5) or -5 (negative five).

In visual basic arithmetic operators workmanship has set the degree of workmanship as follows:

Operator Degrees
^ 1
* / Mod 2
+ - 3

operators who have the same degree will be done starting from the left.
For example there is the statement:
A = 2 + 2-5
seen that there are two of the arithmetic operators + and -. It was decided that the operators + and - have the same degree of craftsmanship so that the operator of the most left will done first. Thus the order of execution of the statement are:
1. 2 + 2 provides the results of 4
2. 4-5 give the results -1
3. -1 was given to a variable A

Suppose there are statements like the following:
A = 2 + 5 * 10, then the process sequence is
1. 5 * 10 = 50
2. 2 + 50 = 52
3. 52 were given to A

We consider the operator * is done in advance rather than operator +. How about if we change the order of workmanship want where desired operator + higher degree of workmanship of the operator *. To do this on a operator operators + plus open parenthesis and close parenthesis so that the form of a statement becomes:
A = (2 +5) * 10, then the order of the process becomes:
1. 2 + 5 = 7
2. 7 * 10 = 70
3. 70 were given to A

If there are parentheses within parentheses, the innermost parentheses to be done first. For example there is a statement as follows:
A = 7 * ((2 +5) * 10), then the sequence of the process becomes:
1. 2 + 5 = 7
2. 7 * 10 = 70
3. 7 * 70 = 490
4. 490 were given to A

Suppose there is a statement as follows:
A = (2 + 5) * 10-15 + 7 ^ 2, then the order of execution of the statement are:
1. 2 + 5 = 7
2. 7 ^ 2 = 49
3. 7 * 10 = 70
4. 70-15 = 55
5. 55 + 49 = 104
6. The value 104 was given to A
READ MORE - Arithmetic operations
 
THANK YOU FOR VISITING