Operators in C language
In this tutorial, we will learn about what are operators and their types with example. There are different types of operators in the C language.
Operator and its types
An operator is simply a symbol that is used to perform operations. There can be many types of operations like arithmetic, logical operations. There are 8 types of operators in the C language.
Types of Operators in C language.
- Arithmetic Operators
- Increment and Decrement Operators
- Assignment Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Conditional Operators
- Special Operators
Arithmetic Operators
An Arithmetic operator performs mathematical operations such as addition, subtraction, multiplication, division, etc on constants or variables.
Example:
Output
Increment and Decrement Operators
There are two operators in C language Increment and Decrement. These two operators are used to increase or decrease the value of an operand by 1.
Increment ++ operator increases the value by 1 whereas Decrement -- decreases the value by 1. These operators require only one operand to perform their operations
Example:
Output
Assignment Operators
An Assignment operator is used for assigning the value to the variable. The commonly used assignment operator is =
Example:
Output
Relational Operators
A relational operator is used to check the relationship between two operands. A relational operator is true or false, if the relational operator is true it returns the value 1 otherwise it returns value 0. Relational operators are used in decision-making statements and loops
Example
Output
Logical operator
Logical operators are used to combining two or more conditions. An expression containing a logical operator returns either 0 or 1 depending upon expression is true or false. Logical operators are used in decision making in C. There are 3 types of logical operators.
Example:
Bitwise Operator
Bitwise operators perform manipulations of data at the bit level. These operators also perform shifting of bits from right to left. Bitwise operators are not applied to float and double Datatypes.
Example:
Output
Conditional Operators
The conditional operator is actually the if condition that we use in decision making in C language but using conditional operator we turn if condition statement into a short and simple operator.
The syntax for the conditional operator is :
Comments
Post a Comment