Question
2 views

Explain various operators in c?

check_circle

Step 1

Operators in C can be categorized into the following:

• Arithmetic operators
• Bitwise operators
• Relational and logical operators
• Assignment operators
• Others

Arithmetic operators: They are used for arithmetic or mathematical operations:

Binary operators: They perform operations between two operands.

• +: It is used to perform addition. For example, a + b
• - : It is used to perform subtraction. For example, a - b
• *: It is used to perform multiplication. For example, a * b
• /: It is used to perform division. For example, a / b
• %: It is used to get the remainder. For example, a % b

Unary Operators: They perform operations with a single operand.

• Post-increment (++): It first executes the statement and then increments the value of an integer. For example, a++
• Pre-increment (++): It is used to instantly increment the value of an integer. For example, ++a
• Post-decrement (--): It first executes the statement and then decrements the value of an integer. For example, a--
• Pre-decrement (--): It is used to instantly decrement the value of an integer. For example, --a
Step 2

Bitwise Operators:

• The & (bitwise AND performs AND on every bit of two numbers. For example, a & b
• The | (bitwise OR) performs OR on every bit of two numbers. For example, a | b
• The ^ (bitwise XOR) performs XOR on every bit of two numbers. For example, a ^ b
• The << (left shift) performs left shift on the bits of the first operand, the second operand decides the number of bits to shift. For example, a << b
• The >> (right shift) performs right shift the bits of the first operand, the second operand decides the number of bits to shift. For example, a >> b
• The ~ (bitwise NOT) inverts all bits of a number. For example, ~a

Relational Operators:

• Equal to operator (‘==’): returns true when the two operands are equal, otherwise it returns false. For example, 2==2 will return true.
• Not equal to operator (‘!=’): returns true when the two operands are not equal, otherwise it returns false. For example, 2!=3 will return true.
• Greater than operator (‘>’): returns true when the first operand is greater than the second operand, otherwise it returns false. For example, 2>1 will return true.
• Less than operator (‘<‘): returns true when the first operand is less than the second operand, otherwise it returns false. For e...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

### Computer Science 