In this part of Algorithm and Programming subject, we were taught of Operations, Operands, and Arithmetic of Algorithm and Programming.
Operators are divided into few types, there are:
- Assignment Operator
- Logical Operator
- Arithmetic Operator
- Relational Operator
- Bitwise Operator
- Pointer Operator
Those Operators have their own functions, for example:
1. Assignment Operators
it is used to assign values to an operand.
Syntax : Operand1 = Operand2;
Or it basically says that Operand1 has the same value with Operand2.
2. Arithmetic Operators
it is used to implicate arithmetic and maths in programmings. All are according to which arithmetic system it implicates.
"+" for adding some value to an operand.
"-" for decreasing some value to an operand.
"*" for timing the value of an operand.
"/" for dividing the value of an operand.
"%" for gaining the modulo of an operand.
"++" for implying an increment to an operand.
"--" for implying a decrement to an operand.
"()" for giving a higher priority to some operation inside the scope.
3. Relational Operators
This is used for comparing values with TRUE or FALSE result. Relational Operations are divided into these types:
"==" for finding which an operand is equal to the other or not.
"!=" for finding the opposite result of what equality operation does.
"<" for finding if an operand is less than the other.
">" for finding if an operand is greater than the other.
"<=" for finding if an operand is less or equals to the other.
">=" for finding if an operand is greater or equals to the other.
"?:" for finding the result whether some certain condition is true or false.
4. Logical Operators
This operator is used for additional logical options for relational operations. It is divided to these types:
"&&" or basically it is "and"
"||" or basically it is "or"
"!" for "not"
The logics of these operators are according to truth table in Discrete Mathematics
5. Bitwise Operators
This kind of operators plays with the bitwise value of each operands. For example:
int A=24,B=35,C,D;
C = A & B; //value of C = 0
D = A | B; //value of D = 59
Notes:
A = 24, binary : 011000
B = 35, binary : 100011
Bit by bit AND operation resulting: 000000, in decimal: 0
Bit by bit OR operation resulting: 111011, in decimal: 59
6. Pointer Operators
The lecturers said that this kind of operator will be discussed in further meetings. But these are what i gained:
Pointer Operators are divided into two:
& (Address of) which shows the address of data by each operand
* (value of) which shows the value of an operand
No comments:
Post a Comment