Operators and Expressions
All processes are done at the Arithmetic & Logic Unit of the computer - ALU. All operations or processes are performed as arithmetic & Logic operations in ALU. C is rich with its efficient operators, using which we can easily write efficient programs.
Operator is nothing but a symbol which instructs the computer what operation it has to perform.
In machine languages, an operator may be a combination of binary 0's and 1's, i.e. there will be a unique 0's and 1's combination for each operations, say for addition, subtraction, comparison etc. In Assembly language we uses the instruction set to perform the operations, for addition operation we may use ADD instruction, similarly CMP instruction can be used for comparison. In modern high level languages, we can use symbols similar to those used in maths or real life to instruct the computer for a particular operation. For example '+' symbol can be used to instruct the computer for an addition operation, similarly '-','*','/' symbols can be used to perform the other 3 arithmetic operations.
An operator tells the computer what to do with the associated operands. Operands are the memory values that we need to manipulate to get the results. So our instructions would be a combination of operators and operands, and such a combination is known as an expression. For example sum=a+b is an expression and contain 3 operands - sum, a, b and two operators '+' and '='. Here + operator directly deal with two operands (a and b) and is used to add two values, so '+' (Addition) operator is a binary operator. An operator is a binary operator if it deal with or uses two operands for operations. '-' (subtraction) operator is a binary operator and uses two operands - minuend and subtrahend, '-' operator can also be used to represent a negative value, say -10, here '-' is associated with only one operand is a 'unary minus'/ unary operator.
Operators are one of the striking feature of C. C supports different types of operators.
Operators in C
1. Arithmetic Operators [ + , - , *, /, % ]
2. Relational Operators [ > , < , >=, <=, ==,!= ]
3. Logic Operators [ &&, ||, ! ]
4. Assignment Operators [ =, +=, -=, *=, /= ]
5. Conditional Operators [ ?, : ]
6. Increment/Decrement Operators [ ++, --]
7. Bitwise Operators [ &, ^, ~, >>, << ]
8. Special Operators [ , . sizeof() -> ]
Operator is nothing but a symbol which instructs the computer what operation it has to perform.
In machine languages, an operator may be a combination of binary 0's and 1's, i.e. there will be a unique 0's and 1's combination for each operations, say for addition, subtraction, comparison etc. In Assembly language we uses the instruction set to perform the operations, for addition operation we may use ADD instruction, similarly CMP instruction can be used for comparison. In modern high level languages, we can use symbols similar to those used in maths or real life to instruct the computer for a particular operation. For example '+' symbol can be used to instruct the computer for an addition operation, similarly '-','*','/' symbols can be used to perform the other 3 arithmetic operations.
An operator tells the computer what to do with the associated operands. Operands are the memory values that we need to manipulate to get the results. So our instructions would be a combination of operators and operands, and such a combination is known as an expression. For example sum=a+b is an expression and contain 3 operands - sum, a, b and two operators '+' and '='. Here + operator directly deal with two operands (a and b) and is used to add two values, so '+' (Addition) operator is a binary operator. An operator is a binary operator if it deal with or uses two operands for operations. '-' (subtraction) operator is a binary operator and uses two operands - minuend and subtrahend, '-' operator can also be used to represent a negative value, say -10, here '-' is associated with only one operand is a 'unary minus'/ unary operator.
Operators are one of the striking feature of C. C supports different types of operators.
Operators in C
1. Arithmetic Operators [ + , - , *, /, % ]
2. Relational Operators [ > , < , >=, <=, ==,!= ]
3. Logic Operators [ &&, ||, ! ]
4. Assignment Operators [ =, +=, -=, *=, /= ]
5. Conditional Operators [ ?, : ]
6. Increment/Decrement Operators [ ++, --]
7. Bitwise Operators [ &, ^, ~, >>, << ]
8. Special Operators [ , . sizeof() -> ]



0 comments:
Post a Comment