In this blog |
---|
assignment operators |
assignment operators
operator | equivalent to |
/= | variable =variable/expression |
*= | variable =variable*expression |
+= | variable =variable+expression |
-= | variable =variable-expression |
&= | variable =variable&expression |
|= | variable =variable|expression |
^= | variable =variable^expression |
<<= | variable =variable<<expression |
>>= | variable =variable>>expression |
examples of assignment operator
#include <stdio.h>
int main()
{
int a=9,b=3;
printf(" a/=b = %d\n ", a/=b );
a=9;
printf(" a*=b =%d\n ", a*=b );
a=9;
printf(" a+=b =%d\n ", a+=b );
a=9;
printf(" a-=b =%d\n ", a-=b );
a=9;
printf(" a&=b =%d\n ", a&=b );
a=9;
printf(" a|=b =%d\n ", a|=b );
a=9;
printf(" a^=b =%d\n ", a^=b );
a=9;
printf(" a<<=b =%d\n ", a<<=b );
a=9;
printf(" a>>=b =%d\n ", a>>=b );
return 0;
}
output
a/=b = 3
a*=b =27
a+=b =12
a-=b =6
a&=b =1
a|=b =11
a^=b =10
a<<=b =72
a>>=b =1
No comments:
Post a Comment