Introduction to C

Data Types in C

Operators in C

Hello World Program

Add-Sub-Mul-Div Program

Swapping Program

If Else

Loops in C

While Loop

doWhile Loop

For Loop

Switch statement

Goto statement

Arrays

Single Dimensional Array

Two Dimesnional Arrays

Array Example Programs

Pointers

Functions

Strings

Structures

File Handling

Graphics

__Operators in C__

To understand the different operators in 'C' , first let us understand about operators.

**Operator:-** An operator is a symbol that operates on a certain data type and produces the output as the result of
operation.

For example:-

x = y + z.

In this case: '+' is the operator and y,z are operands.

Now, let us know the different operators in 'C'.

There are three categories of operators in 'C'. They are:

**1. Unary Operators**

It is an operator which operates on one operand or say it operates on itself. For example: increment and decrement operators. Examples: ++ -- ! etc.

These operators are operators which operate on two operands. For example: x+y. Here, '+' operats on two operands.

An operator which operates on three operands.

Operators can also be classified on the basis of type of operations performed by them.

They are as follows:-

Arithmetic operators include the basic addition(+), Subtraction(-), Multiplication(*) and Division(/) operations. One more operator is there called modulus operator(%). Hope, everyone is aware of +,-,*,/ operations.

Here, the only new term is modulus operator. Let us understand this operator.

Modulus operator gives the remainder left on division operation. It is noted that its symbol is % but its not the percentage.

For example:-

10%3 = 1

Here, we divided 10 by 3 i.e 10/3. In this case, there will be quotient 3 and the remainder 1. So, remainder 1 will be the result.

Some more examples are here:

20%4 = 0

25%7 = 4

27%8 = 3

These operators compare operands and return 1 for true or 0 for false. Examples of relational operators are:-

< Less than

> Greater than

<= Less than or equal to

>= Greater than or equal to

== Equal to

!= Not equal to

These operators are used to compare or evaluate logical and relational expressions. There are 3 logical operators in 'C' language. They are:-

An assignment operator (=) is used to assign a value to a variable. It may be a constant value or a value of a variable.

For example:-

x = 5; // Here, value 5 is copied to x

x = a; // Here, value of a is copied to x.

Other assignment operators are:

+=

-=

*=

/=

%=

These can be understood as follows:-

Suppose we write

x+=5;

It means as x = x+5;

Similarly, x-=10; // It means x=x-10;