Operators

Filed under , on Thursday, February 18, 2010

0

What is Operators
Operators are symbols that act upon data.They represent a particular operation to be performed on the data. The operations performed are:
Mathematical:
o    Add
o    SubtractOperator
o    Multiply
o    Divide
o    Exponentiation
o    Modulus
Comparison:
o    Greater than (>)
o    Less than (<)
o    Greater than or equal to (>=)
o    Less than or equal to (<=)
o    Equal to (= (Basic style) or = = (C style))
o    Not equal to (<>(Basic style) or != (C style))
Logical
o    AND
o    OR
o    NOT
    Consider the following line:
    9 + 2
The above line indicates that the two numbers, 9 and 2, are to be added.
The ‘+’ symbol used in the above example indicates the operation that is to be performed on the two numbers. It is referred to as an operator.
Thus, operators specify the action that is to be performed on the given data.
‘9’ and ‘2’, the numbers to be added are called the operands.
Thus, an operand is the data on which the operator acts upon.



Classification  
Depending on the nature of operation, operators and classified as:
o        Arithmetic operators
o        Comparison operators
o        Logical operators
  
Arithmetic Operators
Operators that denote the mathematical operations are:
o        Add
o        Subtract
o        Multiply
o        Divide
o        Exponentiation
These are referred to as arithmetic operators.
The following table presents arithmetic operators we have used all our lives:

Data Types

Filed under , on Thursday, February 04, 2010

0

Different types of data are stored in variables. Some examples are:
•    Numbers
Whole numbers. For example, 10 or 178993455
    Real numbers. For Example, 15.22 or 15463452.2511
    Positive numbers
    Negative numbers
•    Names. For example, John
•    Logical values. For example, Y or N   
The data that is to be stored in variables is of different types and so it requires different amounts of memory.
A data type decides the amount of memory to be allocated to a variable to store a particular type of data.
    To allocate memory for a particular piece of data we have to:
    Declare a variable of a particular data type.
The term, declaring a variable, means that some memory is allocated and that portion of memory will be referred to by the variable name.
    The general form of declaring a variable is:
    Data Type [Variable Name]        (C style)
    Dim [Variable Name] as Data Type    (Basic style)
Data types, which are commonly used in programming tools can be classified as:
•    Numeric: Stores numeric value.
•    Alphanumeric: Stores descriptive information
These data types can have different names in different tools. For example, a numeric data type is called int in the tool C while Visual Basic refers to it as Integer. Similarly, an alphanumeric data type is named char  in C while in Visual Basic it is named string. In any case, the data stored is the same. The only difference is that the variables used in a tool have to be declared with the name of the data type supported by that tool.

Numeric data   
Numbers of any type constitute numeric data. The numbers may be whole or real.
Numeric data can contain:
•    Only the numeric characters of 0 to 9
•    The decimal point
The most important numeric data types are Integer, Float and Double.
Integer    
The data type, which stores numeric data is one of the basic data types in any programming language. It consists of a sequence of one or more digits.
For example in Visual Basic, to store an integer value in a variable called ‘num’ the declaration would be as follows:
    Dim num as Integer