Operators in C Language
- C programming consists of many built-in operators. An or Variable. For example, + is an operator that adds numbers.
- Operators with one or more variables, constants, or operands. Variable, constant, operands, function, and operators an expression.
- Expression is operands and operators. Operands are variables that, together with operators, perform certain operations.
Types of Operators in C
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Ternary or Conditional Operators
- Assignment Operator
- Special Operator
|Type of Operator||Symbolic representation|
|Arithmetic operators||+, -, *, /, %|
|Relational operators||>, <, ==, >=, <=, !=|
|Logical operators||&&, ||, !=|
|Increment and decrement operator||++ and —|
|Bitwise operator||&, |, ^, >>, <<, ~|
Arithmetic operators are used to perform mathematical operations such as addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
|+||This operator is used to connect two operands.|
|–||This operator is used to subtract two operands.|
|*||This operator is used to multiply two operands.|
|/||This operator is used to divide two operands.|
|%||This operator is used to partition the modulus of two operands.|
Increment and Decrement Operator
Both the Increment and Decrement operators are very useful operators commonly used to reduce calculations, i.e., ++ x and x ++ means x = x + 1, i.e., increasing the value 1 in X and – x and x– means x = x – 1, i.e., subtracting one value in x. But there is little difference between ++ or −− written before or after the operand. The pre-increment first adds 1 to the operand, and then the result is assigned to the variable on the left, while the post-increment first assigns a value to the variable on the left and then adds one operand.
|++||Increment operator – Increases integer values one by one.|
|−−||Decrement operator – Decreases integer values one after another|
Relational operators are used to compare two values. Hence it is also.
|==||equal to operator. This two values. If both values are equal, then it returns true.|
|!=||This operator is called Not equal to operator. It is used to check that two operands are not equal. Meaning this operator is used to check the value of two operands; if both operands do|
not have equal value, then it returns true.
|>||This operator is called Greater than the operator. It checks the first operand’s value more than the second. If the value of the first operand is greater than the value of the second operand, then it|
returns true like (5> 2) return true
|<||This operator is called a Less than the operator. It is used to check the value of the first operand less than that of the second.|
If the value of the first operand is smaller than the value of the second operand, then it
returns accurately, such as (3 <4) return true
|>=||This operator is called Greater than equal to the operator. It is used to check the value of the first operand greater than and similar to the value of the second operand. If the value of the first operand is greater than or equal to the value of the second operand, it returns accurately as (5> = 5) return true.|
|<=||This operator is called Less than equal to the operator. It is used to check the value of the first operand less than that of the second. If the value of the first operand is smaller than or equal to the value of the second operand, it returns accurately as (5 <= 5) return true.|
There are three types of Logical operators in C; when we have to choose one of the two conditions, we use Logical Operators. && – and, || – or,! – Not.
|&&||Logical AND||(a && b) is false|
|||||Logical OR||(a || b) is true|
|!||Logical NOT||(!a) is false|
In C language, the bitwise operator is used to perform bit-level operations.
|^||Bitwise exclusive OR|
|size of()||This operatortype.|
|&||of the operator variable.|
|*||The pointer variable is used to denote.|