what is operators in c language – computerstutorial

How Many Operators in c language

Operators In C Language  are special symbols which used to perform some operation between values or variables. The operation can be addition, multiplication, division, comparison etc. c language included following types of operatore

Binary Operators

This type of  Operator cannot work with single value or variable, it requires two values around the operator. For example,

Salary = basic * 100;    

Binary Operator Table

Operators in c language
Operators in c language – Operatore Table

Arithmetic Operator

Arithmetic operators used for arithmetic perform operation. Suppose a = 5 and b = 5. operation show in the table

 Operator Description Example
+ Adds two operands a + b = 10
Subtracts second operand from the first a – b = 0
 * Multiply both operands a * b = 25
/ Divide numerator by denominator a / b = 1
% Modulus Operator and remainder of after an integer division a % b = 0

Relational Operator

Relational operators used for relational operation like equal to, less then, greater then etc. Suppose a = 5 and b=5.

Operator Description Example
== Checks if the value of two operands is equal or not, if yes then condition becomes true. (a == b) is true
!= Checks if the value of two operands is equal or not, if values are not equal then condition becomes true. (a != b) is false
Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. (a > b) is not true
Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. (a > b) is not true
Checks if the value of left operand is less than the value of right operand, if yes then condition becomes true. (a < b) is not true
>= Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. (a >= b) is true
<= Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. (a<=b) is true

 Logical Operators

Logical operator are used to perform logical operation in the programming C Language Operator like AND, OR, NOT operations.

&& Called Logical AND operator. If both the operands are non zero then then condition becomes true. (a && b) is true
|| Called Logical OR Operator. If any of the two operands is non zero then then condition becomes true. (a || b) is true
! Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false. !(a && b) is false

 

Assignment Operators

Assignment operators are used to assign a value to variable.

ExampleIf

A = 5; and

B = 0;

then, A = B means A = 0; the value of  B is assigned to A.

There are some short hand operators that enable us to perform some operation and assign the result to operand.

Example:

if we want to do A =  A + B, then we write it as ( A += B)   

Unary Operators 

This type of Operators in c language are used to perform an operation with single variable or value. It not required two values to operator. while binary operator required two variable or value,  For example, to increase a values of a variable we use    

                                                         salary++;

Here salary is a variable name. When we use it the salary will be incremented     by 1. Means if salary was 1000 then after operation salary will be 1001. uanary operator below in the table

Operators in c language
Operators in c language- Unary Operators table

Increment/Decrements Operators

Increment and decrements operators are used to perform addition and subtraction by 1 respectively. If we have A = 1 and B = 5 then

++ Used to perform addition by 1 A++ means ( A =2)
Used to perform subtraction by 1 B—means (B= 4)

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *