In this article we are discussed about various types of operators in c language used. There are 8 types of operators in c language are used are explained along with description.
C operators:
- Operators are the one who performs operation on numbers and values.
- In programming these are the symbols which are used to perform mathematical operations or logical operations.
- C programming language contains its own set built-in operators.
- Operators take part in a program to perform various operations like data manipulation, mathematical or logical expressions.
There are following types of operators:
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Assignment Operators
- Increment and Decrement Operators
- Conditional Operator
- Bitwise Operators
- Special Operators
1. Arithmetic Operators
These operators are used to performing mathematical calculations like addition (+), subtraction (-), multiplication (*), division (/) and modulus (%).
Operator |
Description |
+ |
Addition |
– |
Subtraction |
* |
Multiplication |
/ |
Division |
% |
Modulus |
2. Increment and Decrement Operators
These operators are useful operators used to minimize the calculation, that means ++i and i++.
It means a=a+1 and a−−means a=a-1.
The pre-increment first add one to the operand and then the result is assigned to the variable on the left.
Post-increment first assigns the value to the variable on the left and then increment the operand.
Operator |
Description |
++ |
Increment |
−− |
Decrement |
3. Relational Operators
They are used to comparing two values.
Operator |
Description |
== |
Is equal to |
!= |
Is not equal to |
> |
Greater than |
< |
Less than |
>= |
Greater than or equal to |
<= |
Less than or equal to |
4. Logical Operators
C programming provides three logical operators.
In logical operators we are checking more than one condition for making decisions.
These are: && (meaning logical AND),
|| (meaning logical OR) and
! (meaning logical NOT).
Operator |
Description |
&& |
And operator. It performs logical conjunction of two expressions. (if both expressions evaluate to True, result is True. If either expression evaluates to False, the result is False) |
|| |
Or operator. It performs a logical disjunction on two expressions. (if either or both expressions evaluate to True, the result is True) |
! |
Not operator. It performs logical negation on an expression. |
5. Bitwise Operators
They are useful for bit operation between two variables.
Operator |
Description |
<< |
Binary Left Shift Operator |
>> |
Binary Right Shift Operator |
~ |
Binary Ones Complement Operator |
& |
Binary AND Operator |
^ |
Binary XOR Operator |
| |
Binary OR Operator |
6. Assignment Operators
These operators applied to assign the result of an expression to a variable.
C programming has a collection of shorthand assignment operators.
Operator |
Description |
= |
Assign |
+= |
Increments then assign |
-= |
Decrements then assign |
*= |
Multiplies then assign |
/= |
Divides then assign |
%= |
Modulus then assign |
<<= |
Left shift and assign |
>>= |
Right shift and assign |
&= |
Bitwise AND assign |
^= |
Bitwise exclusive OR and assign |
|= |
Bitwise inclusive OR and assign |
7. Conditional Operator
C offers a ternary operator which is the conditional operator (?: in combination) to construct conditional expressions.
Operator |
Description |
? : |
Conditional Expression |
8. Special Operators
C supports some special operators
Operator |
Description |
sizeof() |
Returns the size of a memory location. |
& |
Returns the address of a memory location. |
* |
Pointer to a variable. |
Related Articles:
- Basic Accounting Concepts Part 1
and operator in carithmetic operators in cassignment operators in cbinary operator in cincrement and decrement operators in cleft shift operator in cmodulus operator in coperators in c languageoperators in c programmingrelational operators in csizeof operator in cspecial operators in ctypes of operators in cunary operator in c
Types of operators in C | Operators in C language
2022-11-16
Computer Basics
No Comments
Admin
In this article we are discussed about various types of operators in c language used. There are 8 types of operators in c language are used are explained along with description.
C operators:
There are following types of operators:
1. Arithmetic Operators
These operators are used to performing mathematical calculations like addition (+), subtraction (-), multiplication (*), division (/) and modulus (%).
2. Increment and Decrement Operators
These operators are useful operators used to minimize the calculation, that means ++i and i++.
It means a=a+1 and a−−means a=a-1.
The pre-increment first add one to the operand and then the result is assigned to the variable on the left.
Post-increment first assigns the value to the variable on the left and then increment the operand.
3. Relational Operators
They are used to comparing two values.
4. Logical Operators
C programming provides three logical operators.
In logical operators we are checking more than one condition for making decisions.
These are: && (meaning logical AND),
|| (meaning logical OR) and
! (meaning logical NOT).
5. Bitwise Operators
They are useful for bit operation between two variables.
6. Assignment Operators
These operators applied to assign the result of an expression to a variable.
C programming has a collection of shorthand assignment operators.
7. Conditional Operator
C offers a ternary operator which is the conditional operator (?: in combination) to construct conditional expressions.
8. Special Operators
C supports some special operators
Related Articles:
Some More: DBMS/ WT/ DMDW
and operator in carithmetic operators in cassignment operators in cbinary operator in cincrement and decrement operators in cleft shift operator in cmodulus operator in coperators in c languageoperators in c programmingrelational operators in csizeof operator in cspecial operators in ctypes of operators in cunary operator in c