operators in c program





C-Operators

An operator is used to do some operation taht can be performed on data.There are eight types of operators in C to do the operations. thery are



Types of Operators

  • Arithmetic operators

  • Relation operators

  • Logical operators

  • Conditional operators

  • Increment / Decrement operators

  • Bitwise operators

  • Special operators

  • Short hand assignment operators



Arithmetic operators
Arithmetiic operator s are used to do the arithmetic Calculation

The general form is

variable1 AO Variable2
variable -constant(or) variables
AO-Arithmetic operator

OPERATOR OPERATION EXAMPLE

  1.      +   Addition   x=2+2
  2.     -   Subraction   y=10-4
  3.     *   Multiplication   z=2*2
  4.     /   Division   a=8/2
  5.     %   Modulo   b=3%2




Relation operators
Relation operation is used to find out the relationship between two given variable.

The general form is
Operand1 RO Operand2
operand-variables
RO-relational operator


  1.     >   greater than   A > B
  2.     <   less than   A < B
  3.     >=   greater than equal to   A>=B
  4.     <=   less than equal to   A<=B
  5.     ==   equal to   A==B
  6.     !=   not equal to   A!=B




Logical Operator
Logical operation is used to find out the relationship between relational Expression.

The general form is
Operand1 LO Operand2
where the,
operand - variable
LO - Logical Operator

  1.   &&   AND   X&&Y
  2.   ||   OR   X||Y
  3.   !   NOT   X!X=X




Increment / Decrement Operator
Increment Operator
++ is the increment operator. yhis adds 1 to the value contained in the variable.The general form is

Variable ++     ++ variable
Example
1. a++ which is equal to a=a+1
2. ++a which is equal to a=a+1



Decrement Operator
-- is the Decrement operator. this subtracts 1 to the value contained in the variable.The general form is

Variable--     -- variable
Example
1. a-- which is equal to a=a-1
2. --a which is equal to a=a-1


youtube tutorial


Comments

Popular posts from this blog

nested-if

switch-statement