Operators in C Language

An operator is a symbol used to perform mathematical and logical operations in a program. C programming language supports rich set of operators .Based on the no of operands used in the operation, operators may be categorized as following…

1. Unary Operator :- only single operand is required to operate.

eg: increment operator ++
    ( further two types are: pre increment ++a and post increment a++).
    decrement operator – –                                                                                                                                                ( further two types are: pre decrement a and post increment a – –). 

 

2. Binary Operators :- require two operands to operate.

a. Arithmetic Operators ( + , , * , etc )                                                                                                                   modules operator % gives the remainder part (eg: 7 % 3 gives 1).

b. Relational Operators ( < , <= , > , >= , == , != )

c. Assignment Operators ( = ) :                                                                                                                                    This operator assigns the right value to the left side operand.

d. Logical Operators:

  • logical and&& ) used to combine multiple conditions (return true if all conditions are true).
  • logical or|| ) used to combine multiple conditions (return true if any of the conditions is true).
  • logical not ( ! ) Returns True if condition is False and returns False if it is True.

e.Bitwise Operators ( & , | , ^ , ~ , >> , << )                                                                                                                The bitwise operators are used to perform bit level operations in C programming language. When we use the bitwise      operators, the operations are performed based on the binary values. 

eg: if two variables A and B are:
A = 25 (11001) and B = 20 (10100)
then, A & B ⇒ 16 (10000)  

3. Ternary Operator :-

The Ternary operator, also called as conditional operator requires three operands. This operator is used for decision making. In this operator, first we verify a condition, then we perform one operation out of the two operations based on the condition result. If the condition is TRUE the first option is performed, if the condition is FALSE the second option is performed.

4. Special Operator :-

There are some other special operators like size of, dot. (used in structure), * pointer etc.

Video/ C Introduction

Watch video in full size
Wordpress Social Share Plugin powered by Ultimatelysocial