C OPERATORS
The operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C language is rich in built-in operators and provides the following types of operators:
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Assignment Operators
5. Increment and Decrement Operators
6. Conditional Operators
7. Bitwise Operators
8. Special Operators
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
C Operators
1. Prepared By –
1) Yash N. Modi
796 , Computer
150170107060
2) Nitin R. Goswami
791 , Computer
150170107031
Topic :-
2. An operator is a symbol that tells the compiler
to perform specific mathematical or logical manipulations. C
language is rich in built-in operators and provides the
following types of operators:
1. Arithmetic Operators
2. Relational Operators
3. Logical Operators
4. Assignment Operators
5. Increment and Decrement Operators
6. Conditional Operators
7. Bitwise Operators
8. Special Operators
3. Arithmetic Operator :-
The arithmetic operator is a binary operator,
which requires two operands to perform its operation of
arithmetic. Following are the arithmetic operators that are
available
Operator Description :-
+ Addition
- Subtraction
/ Division
* Multiplication
% Modulo or remainder
At the time of using the division operator on two integers,
the result will also be an integer. E.g. 100/8 will
result in 12 and not 12.50.
4. Relational Operators :-
Relational operators compare between two
operands and return in terms of true or false i.e. 1 or 0. In C
and
many other languages a true value is denoted by the integer
1 and a false value is denoted by the integer 0.
Relational operators are used in conjunction with logical
operators and conditional & looping statements.
Following are the various relational operators :-
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
== Equal to
!= Not equal to
5. Logical Operators :-
A logical operator is used to compare or
evaluate logical and relational expressions. There are three
logical
operators available in the C language.
Operator Meaning
&& Logical AND
|| Logical OR
The ! (Logical NOT) operator is a unary operator.
This operator inverses a logical result.
E.g. if a = 5 and b = 7, then
!(a == b)
will evaluate to be true. This expression works as follows,
a==b evaluates to be false, now because of the !
(NOT) operator, the false is inverted to be true.
6. Assignment Operator :-
An assignment operator (=) is used to assign a
constant or a value of one variable to another.
Example:
a = 5;
b = a;
interest rate = 10.5
Increment and Decrement Operators :-
The increment and decrement operators
are very useful in C language. They are extensively used in
for and
while loops.
The syntax of these operators is given below.
7. ++
--
The ++ operator increments the value of the variable by
one, whereas the -- operator decrements the value of
the variable by one.
These operators can be used in either the postfix or prefix
notation as follows:
Postfix: a++ or a--
Prefix: ++a or
In the postfix notation, the value of the operand is used first
and then the operation of increment or decrement
takes place. In the prefix notation, the operation of
increment or decrement takes place first after which the
new value of the variable is used.
8. Conditional Operator :-
A conditional operator checks for an expression, which
returns either a true or a false value. If the condition
evaluated is true, it returns the value of the true section of
the operator, otherwise it returns the value of the
false section of the operator.
Its general structure is as follows:
Expression1 ? expression 2 (True Section): expression3
(False Section)
Example:
a=3,b=5,c;
c = (a>b) ? a+b : b-a;
The variable c will have the value 2, because when the
expression (a>b) is checked, it is evaluated as false.
Now because the evaluation is false, the expression b-a is
executed and the result is returned to c using the
assignment operator.
9. Bitwise Operator :-
Bitwise Operator are used to manipulate data
at bit level. These operators are used for testing the bits or
shifting them right or left. Bitwise operator are not applied to
float or double.
Operator Description
& Bitwise AND
| Bitwise OR
^ Bitwise Exclusive OR
<< Shift left
>> Shift right
Special Operator :-
C supports some special Operator such as
comma, sizeof, etc.