Assignment Operators in C, all in one

C Programming Language / Operators and Enums in C Language

23334

Program:

//Assignment operator 

#include"stdio.h"
void main() {
 int a = 21;
   int c ;

   c =  a;
   printf(" =  Operator Example : Value of c = %d\n", c );

   c +=  a;
   printf(" += Operator Example : Value of c = %d\n", c );

   c -=  a;
   printf(" -= Operator Example : Value of c = %d\n", c );

   c *=  a;
   printf(" *= Operator Example : Value of c = %d\n", c );

   c /=  a;
   printf(" /= Operator Example : Value of c = %d\n", c );

   c  = 200;
   c %=  a;
   printf(" %= Operator Example : Value of c = %d\n", c );

   c <<=  2;
   printf(" <<= Operator Example, Value of c = %d\n", c );

   c >>=  2;
   printf(" >>= Operator Example, Value of c = %d\n", c );

   c &=  2;
   printf(" &= Operator Example, Value of c = %d\n", c );

   c ^=  2;
   printf(" - ^= Operator Example, Value of c = %d\n", c );

   c |=  2;
   printf(" |= Operator Example : Value of c = %d\n", c );

}

Output:

 =  Operator Example : Value of c = 21
 += Operator Example : Value of c = 42
 -= Operator Example : Value of c = 21
 *= Operator Example : Value of c = 441
 /= Operator Example : Value of c = 21
 = Operator Example : Value of c = 11
 <<= Operator Example, Value of c = 44
 >>= Operator Example, Value of c = 11
 &= Operator Example, Value of c = 2
 - ^= Operator Example, Value of c = 0
 |= Operator Example : Value of c = 2
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.