Assignment Operator :
An Assignment operator is used to form an assignment expression, which assigns the value to an identifier. The most commonly used assignment operator is = . Assignment expressions that make use of this operator are written in the form<
Identifier=expression;
Example:
i=100;
j=200;
Other forms of assignment operators exist that are obtaining various operators such as +,-,*,/,% etc with the = sign.
operator | Equation | Output | ||||||
+= | i=i+1 | i+=1 | ||||||
-= | i=i-10 | i-=10 | ||||||
*= | i=i*11 | i*=11 | ||||||
/= | i=i/12 | i/=12 | ||||||
%= | i=i%5 | i%=5 |
C – ASSIGNMENT OPERATORS EXAMPLE PROGRAM :
1 2 3 4 5 6 7 8 9 10 11 12 |
#include<stdio.h> #include<conio.h> int main() { int a=123,b; b=a+2; clrscr(); printf(“Value of a = %d\n”,a); printf(“Value of b =%d ”,b); getch(); return 0; } |
Output:
Value of a = 123
Value of b = 125 |