Study of Operators in C.

C-Operators

 The symbols which are used to perform logical and mathematical operations are called C-operators.
These C operators join individual constants and variables to form expressions. Operators, functions, constants, and variables are combined together to form expressions.

Example: A + B * 5
Where,
  • +, *  -  operators
  • A, B  -  variables
  • 5  -  constant
  • A + B * 5  -  expression

. . .


- Types -


Arithmetic Operators :

These operators are used to perform mathematical calculations like addition, subtraction, multiplication, division, and modulus.

Sr. No    |    Operator    |    Operation
    1                        +                  Addition
    2                        -                  Subtraction    
    3                        *                  Multiplication                   
    4                        /                   Division
    5                        %                Modulus


. . .


 Assignment Operators :

These operators are used for assigning a value to a variable. The most common assignment operator is 

Sr. No    |    Operator    |      Example    |    Same as                     
   1                        =                    a = b                  a = b
   2                      +=                   a += b                a = a + b 
   3                       -=                   a -= b                 a = a- b
   4                     *=                    a *= b               a = a * b   
   5                      /=                     a /= b                a = a / b
   6                     %=                   a %= b              a = a % b

 

. . .


 Logical Operators :

These operators are used to perform logical operations on the given two variables.


Sr. No    |    Operator    |    Example
    1                       &&                 x && y
    2                        ||                    x || y    
    3                        !                     x (x || y), !(x && y)

 

. . .


Relational Operators :

A relational operator checks the relationship between two operands. If the relation is true, it returns 1; if the relation is false, it returns value 0.

Sr. No    |    Operator    |    Meaning of Operator
    1                       ==                 Equal to
    2                        >                  Greater than    
    3                        <                  Less than
    4                       !=                  Not equal to
    5                       >=                 Greater than or equal to   
    6                       <=                 Less than or equal to


. . .


Bitwise Operators :

These operators are used to perform bit operations.


Sr. No    |    Operator    |    Meaning of Operator
    1                       &                 Bitwise AND
    2                       |                  Bitwise OR    
    3                       ~                Bitwise NOT
    4                       ^                  XOR
    5                      <<                Left Shift   
    6                      >>                Right Shift 

 

. . .


Conditional Operators :

Conditional operators return one value if the condition is true and returns another value if the condition is false. This operator is also called a ternary operator.

Syntax: (Condition? true_value: false_value);

Example:     (A > 100 ? 0 : 1);

                        Here, if A is greater than 100, 0 is returned else 1 is returned. This is equal to if-else conditional statements.




. . .


Increment and Decrement Operators :

C programming has two operators increment ++ and decrement -- to change the value of an operand (constant/variable) by 1.


Increment ++ increases the value by 1 and decrement -- decreases the value by.

These operators, meaning they only operators on a single operand.

 

. . .


Sizeof () Operator :

The size of a character is always 1 byte but, the size of int, float, and double variables differs from system to system. This program will compute the size of int, float, double, and char of your system using sizeof operator.
 
The syntax of sizeof operator is:

temp = sizeof(operand);








*(If you find difficulty in reading we request you to try rotating the screen.)



Comments

Popular posts from this blog

ATM solution in C language.- Codechef

MOTIVATION SOLUTION IN C LANGUAGE | CODECHEF | IMDB

APPLE AND ORANGE | HACKERRANK | PROBLEM SOLVING | SOLUTION IN C