Types of Operators in C Language –

Types of operators in C Language

C is a general-purpose, structured programming language. It is reliable, easy to use that’s the reason it becomes one of the popular languages.

Definition of Operator – Operator is defined as a function that operates on one or more variables/constants and manipulates the data and generates meaningful results.

It is very important to understand all the operators in a programming language and how the operators work and how we can use them in our programs. For every program, you need to apply one of the operators.

C language provides a wide variety of operators and they are very easy to understand and apply in your programs.

We will be discussing all the operators one by one and will be giving an example of each operator with an example. If you do not know anything, read the article first Introduction to c language. and How to run the first code in C language?.

Types of operators in C language –

Operator CategoryOperator Symbol
1. Unary Operators -,++, ! , —
2. Arithmetic Operators *, /, %, +, –
3. Relational Operator <, <=, >, >=
4. Assignment Operator =, +=, -=, *=, %=
5. Equality Operator ==,!=
6. Logical And &&
7. Logical OR||
8. Conditional Operator ?

Now let’s understand all the operators with an example one by one.

1. Unary Operator

Basically, all the operators work on two operands but the specialty of unary operators is that they work on a single operand. In Unary operators, we have four types of operators in the C language.

Example of Unary Operator –

Output – The value of a is 5 The value of a after the increment is 6

2. Arithmetic Operator –

Mainly arithmetic is used to perform basic mathematic calculations. We need two or more operands for applying the arithmetic operators.

All the basic functions like addition, subtraction, multiplication, and division are under the arithmetic operators.

Example of Arithmetic Operators –

If you did not get the program. Check the program C Program to add two numbers. In the above program, We added two variables using the ‘+’ operator.

Output – The addition of a & b is 37

3. Relational Operator –

Relational Operator is applied to two or more variables and is used to compare the variables. It compares the variables and returns true/1 if the comparison is true and false/0 if the statement is false.

Example of Relational Operator –

Output : Enter the values of a and b 10 20 The comparison is 1.

If you want to check more programs related to the relational operator click here.

4. Assignment Operators –

From the name, you can get the idea. Assignment means assigning a value to something. Assignment Operators are used to assigning value to the variables. Variables can be assigned in many different ways as listed in the table.

Example of Assignment Operator –

Recommended Posts

  1. Introduction to c language
  2. How to run the first code in C language?
  3. C Program to add two numbers
  4. C Program to reverse a number
  5. Difference between c and c++

Leave a Reply

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

Close Bitnami banner