From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/CONCEPT/assignment.html | 91 +++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 reference/C/CONCEPT/assignment.html (limited to 'reference/C/CONCEPT/assignment.html') diff --git a/reference/C/CONCEPT/assignment.html b/reference/C/CONCEPT/assignment.html new file mode 100644 index 0000000..5985d5b --- /dev/null +++ b/reference/C/CONCEPT/assignment.html @@ -0,0 +1,91 @@ +Assignment operators. + +
+
+

Assignment operators.

+
+
+ +C has the following assignement operators: +
+	=   +=   -=   *=   /=   %=   <<=   >>=   &=   ^=   |=
+
+= is the obvious one. It takes the result of the expression on the right +and assigns it to the variable on the left (lvalue). +
+	main ()
+        {
+	  int a, b=4, c=10;
+	  a = b + c;
+	}
+
+I know this is stating the obvious, but: +
    +
  1. b is assigned the value 4 +
  2. c is assigned the value 10 +
  3. a is assigned the result of b plus C (14). +
+ +
+All the other operators act in a simular way. If you find yourself +coding the example on the left, it could be changed to the example on +the right. +
+	main ()				main()
+	{				{
+	  int a=4;			  int a=4;
+	  a = a * 4;			  a *= 4;
+	}				}
+
+The rule is as follows: +

+The lvalue is multiplied by the rvalue and the result assigned to the +lvalue. +

+Here is another example. +

+	main()				main()
+	{				{
+	    int a=10, b=2;	            int a=10, b=2;
+	    a /= b * 5;		            a = a / (b*5);
+	}				}
+
+Again both preduce the same answer (1). +

+


+ + +Increment (++) and Decrement (--)
+ + +Bit shifting ( >>= <<= )
+ + +Operator precedence table. +
+

+

+ + + + +
+Top + +Master Index + +Keywords + +Functions +
+
+

+ +


+
Martin Leslie + +
-- cgit v1.2.3-54-g00ecf