Operators are the foundation of any programming language. Operators in C is a special symbol that tells the compiler to perform specific mathematical or logical function. The data items on which those operators are applied are known as operands.
The following is the list of the operators:
Arithmetic operator: These are the operators used to perform mathematical/arithmetic operations on operands. For Example:
Added two operands
Subtracts second from the first
Multiples both operands
Divide numerator by Denominator
Modulus Operator and remainder of after an integer division
Relational operator: In this relational operator we can compare of the values of two operands.
Here we can show some Example of Relational Operator.Assume variable A holds 10 and variable B holds 20 then
Check the value of two operands are equal or not.If the value are equal then condition become true.
(A==B) is not true
Check the value of two operands are equal or not.If the value are not equal then condition become true.
(A!=B) is true
Check the value of left operand is greater than value of right operand.If yes then condition become true.
(A > B) is not true
Check the value of left operand is less than value of right operand.If yes then condition become true.
(A < B) is true
Check the value of left operands is greater than or equal the value of right operand.If yes than condition become true.
(A >= B) is not true
Check the value of left operands is less than or equal the value of right operand.If yes than condition become true.
(A<=B) is true
Logical operator: In this logical operator are used to combine two or more conditions to complement the evaluation of the original condition in consideration.The result of this operation is a boolean value either true or false. For Example
Logical AND operator. If both the operands are non-zero then condition become true.
(A && B) is false
Logical OR operator.If both operands is non-zero then condition become true.
(A || B) is true
Logical NOT operator.It is used to reverse the logical state of operand.If condition is true then operator will make it false.
!(A && B) is true
Bitwise operator: The Bitwise Operator are used to perform the operations on the data at the bit-level.It consists of two digits, either 0 or 1. We have different types of bitwise operators in C programming language.This is the list of bitwise operators :
Meaning of the Operator
Bitwise AND operator
Bitwise OR operator
Bitwise XOR operator
One's complement operator
Left shift operator
Right shift operator
Let’s look at the truth table of the bitwise operator
Conditional operator: Conditional operator are also called ternary operator is one of the operator which is used in the decision making process.Conditional operator returns the one value if condition is true and return another value is condition is false.
The condition(Expression1) is true then we will execute the condition and then return the result of(Expression2) otherwise if condition (Expression1) is false then we will execute and the result of (Expression3).
Assignment operator: In this Assignment operator are used to assigning value to a variable.The right side operand of the assignment operator is a value and the left side operand of the assignment operator is a variable.
Different types of assignment operators are shown below:
Those operator are used to assign the value on the right to the variable on the right.
Those operator first add the current value of the variable and then assigns the result to the variable.
(a+=b) can be written as (a=a+b)
Those operator first subtract the current value of the variable and the assigns the result to the variable.
(a-=b) can be written as(a=a-b)
Those operator first multiplies the current value of the variable and then assigns the result to the variable.
(a*=b) can be written as (a = a*b)
Those operator first divides the current value of the variable and then assigns the result to the variable.
(a/=b) can be written as (a = a/b)
The precedence and associativity of operators in C are given below: