What is Operators in C ?
In a simple way, special symbols that are used to perform actions are known as operators.
Let's Describe about types of operators that are used in C language :-
(1) Arithmetic operators :-
Arithmetic operators are used to perform mathematical operation such as addition , subtraction, multiplication, division , modules etc.
Ex-
+ Addition
- Subtraction
* Multiplication
/ Division
% Modules
Program :-
Int a=2;
Int b=3;
Printf("a+b=%d", a+b) ;
(2) Relational operators :-
Relational operators are used for the comparison between two or more numbers.
Ex-
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
== Is equal to
! = Is not equal to
Program :-
Int a=2;
Int b=2;
Printf ( " a == b = %d " , a == b);
Output :-
1 true....
(3) Logical operators :-
There are three logical operators AND, OR & NOT. They can be used to compare boolean values but are mostly used to compare conditions to see whether they are satisfying or not.
AND :- It returns true, When both operators are true or 1.
Ex - If ( a>b && a>c) {
}
OR :- It returns true, When either one operators is true or 1.
Ex - If ( a>b || a>c) {
}
NOT :- It is used to reverse the logical state of the operand.
Symbols Operators
&& AND Operator
|| OR Operator
! NOT operator
(4) Bitwise Operator :-
To perform bit level operations, bitwise operators are used. They convert the values in binary format and then compare them to provide us the results.
Symbols Operators
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
~ Bitwise Comple
<< Shift Left
>> Shift Right
(5) Assignment Operators:-
Assignment operators are used to assign values. They are going to be used in each and everyone of our program.
Operators Description
= Assign value from right side to left side operand.
+= It's add the right operand to the left & assign result to left operand.
-= It's subtract the right operand to the left & assign result to left operand.
*= It's multiply the right operand to the left & assign result to left operand.
/= It's divide the right operand to the left & assign result to left operand.
In next article we will discuss about format specifier and escape sequence in C language. So, Be continue and thanku to visit us 🙏🙏.
If any type of wrong statement or any wrong meaning found just comment 💬💬 Below.. Thanku 🙏🙏🙏
Good one
ReplyDeleteLogical operator && means that if both the term is non zero then it will true
ReplyDeleteAnd || means if any one of them is nonzero then it will give true
Yaa, you are right
Delete