Wednesday, August 10, 2011

Arithmetic Operations

Arithmetic operations are almost always you come across on each program, both programs for engineering problems and other common problems. The discussion chapter will revolve around the various things associated with arithmetic operations, either of a general nature, which you can also meet on other programming languages​​, or of a special nature, which is owned by the C language, Tubo C in particular.

Arithmetic Operator
Arithmetic operations are known by the Turbo C are as follows:

+   add
-    less
/    for
*    times
% remaining

Example:   A = 10 / 2;   results = 5
                   B = 5 +2-3result = 4
If in some other programming language you may find operators for reappointment, but in Turbo C is an unknown type of operator. So if you find formulas reappointment, you have to manipulate it with multiplication or other means which will be discussed later.

Example:     A=X2 
   in Turbo C is written A = X * X;
                     B=5Y3    written in Turbo C B = 5 * Y * Y * Y;

The remaining operators (%) can only be used for data of type char or int, can not be used to float or double.

Example:        A = 5% 2               values ​​A = 1
                                                       the solution is 5 divided by 2 = 2 remainder 1
                        B = 4.3% 3.2         value will be wrong

Arithmetic Expression
In the example above, you come across statements are like A = X * X, the form X * X is called an arithmetic expression. While A = X * X is an assignment statement to a variable. A common form of assignment statement is:
The sign '=' in the above statement is known as the operator giving the value (assignment operator), because the sign '=' is used for member value to a variable, either numeric or character or string.

Left of the sign '=', ie variables, known as an lvalue (Left Value), while the arithmetic expression that terlaetak the right of '=' called RVALUE (Right Value).

Lvalue must always be a single variable, not the other. While RVALUE can be a constant, another variable or an arithmetic expression or formula.

OPERATOR Arithmetic Hierarchy
If in an arithmetic expression you can see the use of several different carriers Artmatika simultaneously, then the hierarchy of these operators is as follows:

Related Posts

No comments:

Post a Comment