4 Types of Operators in C

Preview

Operators

These are the symbols which are used to perform some calculation or manipulation on values which may be in the form of variables, constants or expressions in a C program.

Operand

It is the variable, constant or expression on which an operator performs some calculation, comparison or some other manipulation.
Example 
  6+5      
In the above example, 6 and 5 are operands. + is the operator which is performing addition of 6 and 5

Types of Operators in C

Operators are of various categories as

  • Unary Operators
  • Binary Operators
  • Ternary Operator
  • Special Operators

1. Unary Operators

Unary operators are those operators which have single operand. They are of following types:

a. Unary Plus (+)

It is used to specify that the number is positive. It is an optional sign because a number without any sign is automatically considered positive.

Example

+6, 45

b. Unary Minus (-)

It is used to specify that the number is negative.

Example
  -6, -45

c. Pointer Operator (*)

It is known as pointer or pointer to operator. It is used to declare and use the pointer variable.

Example:
int *ptr;
**Above statement declares a pointer variable ptr of int type.

d. Address operator(&)

It is also known as “address” operator. It is used to store the address of a variable in pointer variable.

Example

int num=10,*ptr;
ptr=#

**Above statement stores the address of variable num in pointer variable ptr.

e. Increment (++) /Decrement (–) Operators

2. Binary Operators

These are the operators which can have two operands. Various categories of binary operators in C language are:-

 

3. Ternary Operator/Conditional operator

Conditional operator is also known as ternary operator.

This operator is known as ternary operator because it has three operands.

Ternary operator is represented as ?: .

Click here for complete topic.

 Special operators

These operators are used for special purposes. There are many special operators provided by C language which are as follows:

 

 Best Books of C



Lesson tags: c operators and its types, types of operators in c
Back to: C Programming Language