Assignment Operators in C Language

Assignment Operators in C Language:

(1) Assignment Operators are used for assigning values to variables

(2) Sample C language code and its output, as shown:

Assignment Operators sample C Language code
#include <stdio.h>
#include <conio.h>
// Assignment Operators in C Language
int main()
{
int x;
  x = 5;
printf(“Value of ‘=’: %d\n”, x);
  x = x + 10;
printf(“Value of ‘+’: %d\n”, x);
  x = x – 9;
printf(“Value of ‘-‘: %d\n”, x);
  x = x * 5;
printf(“Value of ‘*’: %d\n”,x);
  x = x / 5;
printf(“Value of ‘/’: %d\n”, x);
  x =  x % 5;
printf(“Value of ‘%’: %d\n”,x);
  x = x & 4;
printf(“Value of ‘&’: %d\n”,x);
  x = x | 2;
printf(“Value of ‘|: %d\n”,x);
  x = x ^ 4;
printf(“Value of ‘^’: %d\n”,x);
  x = x >> 2;
printf(“Value of ‘>>’: %d\n”,x);
  x = x << 4;
printf(“Value of ‘<<‘: %d\n”,x);
 
getch();
return 0;
}

(3) After that go to the “Build” menu and select the “Build” option for publishing the code as shown.

click on build option for Assignment Operators code in c

(4) After building the code, press the “Run” button, as shown.

click on run button for assignment operator code in c

(5) After pressing the “run” button, the output screen is opened, as shown.

output obtained from assignment operator in c
Assignment OperatorsDescription
=Simple assignment
*=Multiplication assignment
/=Division assignment
%=Remainder assignment
+=Addition assignment
-=Subtraction assignment
<<=Left-shift assignment
>>=Right-shift assignment
&=Bitwise-AND assignment
^=Bitwise-exclusive-OR assignment
|=Bitwise-inclusive-OR assignment

ARRAY in C Language
DO WHILE Loop in C Language
WHILE Loop in C Language
FOR Loop in C Language
Use of BETWEEN Operator in SQL
REVERSE (Transact-SQL)– Microsoft Docs

Leave a Reply