Operators in C language

Operators in C language

Operators in C language
To view other topics related to Computer. Click Here.

Operators in C language

Operator: -

These are the symbols which are used in mathematical calculations or the solution of mathematical problems. There are several types of operators in C language. The following types are commonly used in C language.

(1) Arithmetic operator: -

These operators which are used in arithmetic calculations are called arithmetic operator. These operator are

1. + ( Adding operator ) 2+3 or a+b

2. – ( Subtraction operator ) 2-3 or a-b

3. * ( Multiplication operator ) 2*3 or a*b

4. / ( Division operator ) 2/3 or a/b

5. % ( Mod operator ) 2%3 or a%b

(2) Relational operator: -

Those operators which are used show the relationship between two constant or variable are called relational operator. These are

< (Less then) 5<7 or a> (Grater then) 7>5 or x>y

<= (Less then or equal) 2<=3 or a<=b

>= (Grater then or equal) 3>=2 or a>=b

== (Equal) 5==5 or a==b

!= (Not equal) 5!=7 or k!=m

(3) Logical operator: -

Those operators which are used to join the relational operators. These are

&& (AND operator)

|| (OR operator)

! (NOT operator)

(4) Assignment operator: -

The assignment operator is (==).

(5) Compound assignment operator: -

The compound assignment operators are (+ = > - =, * = > /=, %).

(6) Increment operator: -

The increment operator adds one to the value of the variable. If n is variable having value 10 then following code adds one two the value of n, so that after the statement is executed, n has a value of 11.

Int n =10;

n++;

(7) Decrement operator: -

The decrement operator subtracts one from the value of the variable. The expression --n;

Decrement the value of n one time.

(8) Unary operator: -

These operators are used with single operator or single variable. These are ++ or-- variable operators.

(i) Prefix unary operators: -

These are used before the variables are operators. For example ++! (Prefix) Prefix decrement).

(ii) Post fix unary operator:-

Those unary operators which are used after the unary variable or operators called post fix unary operators. For example! ++ (Postfix).

Post a Comment

Previous Post Next Post