## C Operators and Operands

###### Hello Readers!!!!!

How are you doing? I wish you are doing well. If you face any difficulties then please let me know here with comments.

Today we are going to learn about the Operators and Operands in C.

### What is Operator?

Operators are the foundation of any programming language. We can define operators as symbols that help us to perform specific mathematical and logical computations on operands. In other words, we can say that an operator operates the operands.

If you have missed the previous blogs then you can see them from here,

Let us dive into C Part-4 (Get some inputs from users)

Let us dive into C Part-3 (Data types & Variables)

Let us dive into C Part-2 (Hello World)

For example, we can consider the below expression:

a = b+c;

here, we got a, b, and c are the operands and ‘+’ and ‘=’ are the operators. The ‘+’ is known as the addition operator and ‘=’ is known as the assignment operator. Now, the full expression means to us as, add b and c operands then assign the result to the operand a.

C programming language has many built-in operators. We can classify them as below:

**Arithmetic Operators:** These operators are used to perform the arithmetic and mathematical operations on variables or operands. We can find them in mathematical operations and expressions. They are, (+, -, /, *, %, ++, – -)

We can divide arithmetic operators into two sections.

**Binary Operators: **Operators that operate or work with a single operand are unary operators.

For example: (++ , –)

**Unary Operators: **Operators that operate or work with two operands are binary operators.For example: (+ , – , * , /)

**Relational Operator:** These operators are used to compare the value of two operands. For example: checking if the operand is less than the other operand or not, checking if the operand is greater than the other operand or not, checking if the operand is equaled to the other operand or not. Some of the relational operators are: (==, > , = , <= ).

**Logical Operator:** Logical operators are AND, OR, and NOT operators. They are used to combine two or more conditional expressions. The logical operators are, &&, ||, !

'&&' we call it as AND '||' we call it as OR '!' we call it as NOT

for example, we consider below:

// C program to demonstrate working of logical operators #include <stdio.h> int main() { int a=10, b=4, c = 10, d = 20; // logical operators // logical AND example if (a>b && c==d) printf("a is greater than b AND c is equal to d\n"); else printf("AND condition not satisfied\n"); // logical AND example if (a>b || c==d) printf("a is greater than b OR c is equal to d\n"); else printf("Neither a is greater than b nor c is equal to d\n"); // logical NOT example if (!a) printf("a is zero\n"); else printf("a is not zero"); return 0; }

**Logical AND:** The ‘&&’ operator returns true when both the conditions in consideration are satisfied. Otherwise, it returns false. For example, a && b returns true when both a and b are true (i.e. non-zero).

**Logical OR:** The ‘||’ operator returns true when one (or both) of the conditions in consideration is satisfied. Otherwise, it returns false. For example, a || b returns true if one of a or b is true (i.e. non-zero). Of course, it returns true when both a and b are true.

**Logical NOT:** The ‘!’ operator returns true the condition in consideration is not satisfied. Otherwise, it returns false. For example, !a returns true if a is false, i.e. when a=0.

**Assignment Operator: ** Assignment operators are used to assigning value to a variable. This operator treats the left-sided operand as variable and the right side operands as the value. So, the assignment operator assigns a value from right to the left. For example:

a= 12;

This expression means, assign** 12** to the left side operand denoted as ‘**a**‘.

b = a;

This line assigns the value of ‘a’ to the variable ‘**b**‘ So, the value of **b** will be 12 now.

That’s all for today friends. If you found this post important then you can share it with your friends. To share it with your friends on social media or to email to your dearest one you can use the social media links drawn on the top of this post.

Thank you for your time.