Operators
in C - What are Operators in C programming?
What
are Operators in C programming?
In
today's tutorial series, we will learn about Operators.
What is Operators in
C programming - Explain Operators in C programming.
Operators are the most
important parts in any programming language. Without this we cannot write any
program. Just as brick is required to build a house, similarly we need
Operators to make a program.
What is the Operators in
C programming?
The operator is a symbol that tells the compiler to
perform any mathematical and logical operation. There are a lot of built-in Operators
in C programming.
Such symbols which are used to perform any type of
mathematical and logical operation. They are called Operators in C programming.
In programming, Operators are used
to manipulate data and variables.
Operators work together with
one or more variables, constants or operands. Variable, constant, operands,
function and Operators merge all these together to form an expression.
A combination of operands and Operators is called
Expression.
Operands are variables that together with Operators
perform certain operations. Let us understand Expression by example.
Suppose an expression is given as "A + B - C * 6 +
3". In this, +, -, * these are all Operators while A, B, C are all
these variables which are also called operands.
And both 6 and 3 are constant whose value does not
change. And when Variables, Operators, Constant, function are all added
then the expression is ready.
Types of Operators in
C - Types of Operators in C programming
As you read above, in C programming there are a
lot of built-in Operators which have been divided into different types.
Which is as follows:
1.
Arithmetic
Operators
2.
Assignment
Operators
3.
Relational
Operators
4.
Logical
Operators
5.
Conditional
Operators (Ternary Operators)
6.
Bitwise
Operators
7.
Increment
/ Decrement Operators
8.
Special
Operators
Arithmetic Operators
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
Assignment Operators
|
||||||||||||||||||||||||
Relational Operator
Relational Operator is used to compare the value of two operands hence it is also called Comparison operator.
Relational Operator is used to compare the value of two operands hence it is also called Comparison operator.
|
|||||||||||||||
Logical Operators
- Logical Operators are used to combine two expressions and a condition. These Operators are used to perform logical operations.
list of Logical Operators which are in the table below.
|
||||||||||||||
Conditional Operators (Ternary Operators)
Conditional
Operators are used to check the condition. This operator has only two
options TRUE and FALSE. If the given condition satisfies, then TRUE will return
otherwise FALSE will be return.
This operator is known by two names
- Ternary Operator ?
- Bitwise operator
Syntax of conditional Operators
Condition ? True Expression : False Expression;
Explanation:
• Question mark "?"
Represents if part.
• The condition part gives us either
one type of value either true or false.
If the condition part returns true
value then true expression will execute. That is, the expression on the left
side of ":" will execute.
• If condition part returns false value
then False expression will be executed. That is, the expression on the right
side of ":" will execute.
Bitwise Operator
Bitwise
operator is used to manipulate BIT level data. This operator is used for
shifting from right to left and left to right bit. The bitwise operator does
not apply to float and double data type.
Computer
only works on 0 and 1. The full form of Bit is a binary digit which is 0 and 1.
The bitwise operator is calculated at 0 and 1. Whenever we manipulate the
decimal number by bitwise operator, the processor first converts it to the form
of 0 and 1 and then calculates it.
Operator
|
Description
|
&
|
Bitwise
AND
|
|
|
Bitwise
OR
|
^
|
Bitwise
exclusive OR
|
<<
|
Left
Shift
|
>>
|
Right
Shift
|
Truth
table of Bitwise operator &, |, ^
a
|
b
|
a & b
|
a | b
|
a ^ b
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
1
|
1
|
1
|
0
|
0
|
1
|
1
|
1
|
1
|
1
|
1
|
0
|
Increment / Decrement Operator
The
Increment / Decrement operator is used to increase and Decrease the value of
the variable once. For example, if the variable already has 5 value store, then
its value will be reduced to 6 by increment operator and its value will be 4 by
decrement operator.
- Pre increment / decrement
- Post increment / decrement
Pre
increment / decrement operator
In
the pre increment / decrement operator, first the value increase and decrease
occurs and then the further calculation is performed.
Syntax of pre increment
/ decrement operator
++
(variable name), – – (variable name)
Post
increment / decrement operator
In
the pre increment / decrement operator, first the value increase and decrease
occurs and then the further calculation is performed.
Syntax of post
increment / decrement operator
(variable
name) ++, (variable name) – –
Special Operator
The
special operator is used to perform special work. There are many special Operators
in C programming whose lists are given here.
|
||||||||||||||
Post a Comment
Please do not any spam link in the comment