डाउनलोड पी.डी.एफ. ई-बुक्स
C - Assignment Operators

विवरण :

  • Assignment Operators ग्यारह प्रकार के होते है |
    1. Assignment Operator
    2. Add Assignment Operator
    3. Subtract Assignment Operator
    4. Multiply Assignment Operator
    5. Divide Assignment Operator
    6. Modulus Assignment Operator
    7. Bitwise AND Assignment Operator
    8. Bitwise OR Assignment Operator
    9. Bitwise XOR Assignment Operator
    10.Left Shift Assignment Operator
    11.Right Shift Assignment Operator

    Table for Assignment Operators
    Operator Name of Operator program sum
    = Assignment Operator b = b + a b = 12 + 20 = 32
    += Add Assignment Operator b = b + a b = 32 + 20 = 52
    -= Subtract Assignment Operator b = b - a b = 52 - 20 = 32
    *= Multiply Assignment Operator b = b * a b = 32 * 20 = 640
    /= Divide Assignment Operator b = b / a b = 640 / 20 = 32
    %= Modulus Assignment Operator b = b % a b = 32 % 20 = 12
    &= Bitwise AND Assignment Operator b = b & 2 b = 12 & 2 = 0
    |= Bitwise OR Assignment Operator b = b | 2 b = 0 | 2 = 2
    ^= Bitwise XOR Assignment Operator b = b ^ 2 b = 2 ^ 2 = 0
    <<= Left Shift Assignment Operator b = b << 2 b = 0 << 2 = 0
    >>= Right Shift Assignment Operator b = b >> 2 b = 0 >> 2 = 12

सोर्स कोड :

#include <stdio.h>
#include <conio.h>

void main() {
    
int a=20,b=12;

b = a + b;
printf("value of b is %d",b);    
    
b += a;
printf("value of b is %d",b);    

b -= a;
printf("value of b is %d",b);

b *= a;
printf("value of b is %d",b);    
    
b /= a;
printf("value of b is %d",b);

b %= a;
printf("value of b is %d",b);

b &= 2;
printf("value of b is %d",b);

b |= 2;
printf("value of b is %d",b);

b ^= 2;
printf("value of b is %d",b);

b <<= 2;
printf("value of b is %d",b);

b >>= 2;
printf("value of b is %d",b);

getch ();
}

आउटपुट :

value of b is 32 
value of b is 52
value of b is 32
value of b is 640 
value of b is 32 
value of b is 12 
value of b is 0 
value of b is 2 
value of b is 0 
value of b is 0 
value of b is 0