Wednesday 13 June 2012

BASIC ELEMENTS IN PROGGRAMMING : Mathematical and Logical Operators


Operator is a symbol or notation that tells a computer to perform certain actions or operations.
An example: the plus (+) notation will tell the computer to perform the "add" operation.
Let's look at some examples of Mathematical Operators.


Let's look at some examples of Relational Operators


Let's look at some examples of Logical Operators.



FUNCTION OF MATHEMATICAL OPERATORS

Mathematical operators are notations that tell the computer to perform mathematical operations.

FUNCTIONS OF RELATIONAL OPERATORS

Relational operators perform comparison between two elements.
They return an element of logical 1 (True) where the relation is true, and element of logical 0 (False) where the relation is false.
The diagram shows some common relational operators and their expression.


 
FUNCTIONS OF LOGICAL OPERATORS

Logical operators are notations that tell the computer to perform logical operations.
Examples of Logical operation are: AND, OR, and NOT.
Logical operator compares 2 conditions and returns a TRUE or FALSE value.

AND operator
The diagram below shows a truth table of AND operator.
Notice that truth value of X AND Y is True ( 1 )  if only both X and Y are True ( 1 ).
Else it is false ( 0 )

OR operator
The diagram below shows a truth table of OR operator.
Notice that truth value of X OR Y is only True ( 1 )  if either X or Y are True ( 1 ) or both X and Y are true ( 1 )
Else it is false ( 0 )

NOT operator

The diagram below shows the truth table of NOT operator NOT X is the negation of X, it is essentially the 1's complement operation.
Notice that truth value of NOT X is True( 1 ) when X  is False and vice versa.

 
DIFFERENCES IN MATHEMATICAL AND LOGICAL OPERATORS

Function :
Mathematical operators perform mathematical operations such as plus or substract.
Relational operators perform element-by-element comparisons between two arrays.
Logical operators perform logical operations such as checking the condition of two Boolean values.

Symbols :
These operators have their own symbols based on the programming language.


 
EQUALITY OPERATORS


The equality determine an operand equal to or not equal to another operand.
Remember we must use "=" and not "<>" when testing if two primitive values are equal in Microsoft Visual Basic 6.0.

 __________________________________________________________________________________
 Others Lesson : | click lesson to view |

0 comments:

Post a Comment