In this section of the C tutorial, we will learn about operators in C programming language and its types.
What are operators in the C programming language?
Operators in C programming language is used to perform logical and mathematical operations.
Types of Operators
In C Programming language the types of operators are as follows:
Arithmetic operators
It is used for operations like Addition, Subtraction, Multiplication, division, and modulus are done using arithmetic operators.
The symbol used for Arithmetic Operators in C programming language is “+”.
Example:
int sum=a+b; printf("%d",sum);
Assignment operators
It is used to assign values of the variables.
The symbol used for Assignment Operators in C programming language is =, +=, -=, *=, etc.
Example:
int a=5; int b; b=a;//assigning value of b to a;
Relational operators
It is used for comparison of the value of two variables.
The symbol used for Relational operators in C programming language is ==, != , >, <, >= & <=.
Example:
if(a>5) { return 1;
Logical operators
It is used to control program flow.
Bitwise operators
Used to do bit operations on two variables. The symbol used for Bitwise operators in C programming language is &, |, ^, ~, >> and <<.
Conditional operators (ternary operators)
It is used to execute the first statement if the condition is true and executes another statement if the condition is false.
Increment/decrement operators
It is used to increment or decrement the value of a variable.
Special operators
There are some special operators in C programming Language like &, *, sizeof( ), and ternary operators.