]> zdv2.bktei.com Git - BK-2023-05.git/blobdiff - src/notes.tm
update(src/kr/s1.5):Add exercises
[BK-2023-05.git] / src / notes.tm
index 884ee8cd24c54322bbc17056f582f626670129b8..0d4cac65d7c447da26bf10a84a3094b2b31007e4 100644 (file)
   <section|Terminology>
 
   <\description-compact>
   <section|Terminology>
 
   <\description-compact>
+    <item*|assignment>An expression in which a variable is set to a value.
+    For example, in the expression <hgroup|<cpp|x = 1>>, the variable <cpp|x>
+    is set to the value <cpp|1> because <cpp|x> is to the left of the equals
+    sign \ \P<cpp|=>\Q. The value of the entire expression is equal to the
+    value of the left hand side (i.e. <cpp|x> in this example) after the
+    assignment is performed. For example, the following C code will print
+    \P<cpp|true>\Q:
+
+    <\cpp-code>
+      #include \<less\>stdio.h\<gtr\>
+
+      int main() {
+
+      \ \ int c;
+
+      \ \ if( (c = 7) == 7 )
+
+      \ \ \ \ printf("true");
+
+      \ \ else
+
+      \ \ \ \ printf("false");
+
+      };
+    </cpp-code>
+
+    As another example, the following lines are equivalent:
+
+    <\cpp-code>
+      a = b = c = 0;
+
+      a = ( b = ( c = 0 ) );
+    </cpp-code>
+
     <item*|declaration<label|term declaration>>A construct that establishes
     an association between a particular variable, function, or type and its
     attributes. (See <hlink|cppreference.com|https://en.cppreference.com/w/c/language/declarations>
     <item*|declaration<label|term declaration>>A construct that establishes
     an association between a particular variable, function, or type and its
     attributes. (See <hlink|cppreference.com|https://en.cppreference.com/w/c/language/declarations>
     <associate|func getchar|<tuple|1.2.1|?>>
     <associate|func putchar|<tuple|3|?>>
     <associate|ref includehelp-oct-hex|<tuple|1.1.1|?>>
     <associate|func getchar|<tuple|1.2.1|?>>
     <associate|func putchar|<tuple|3|?>>
     <associate|ref includehelp-oct-hex|<tuple|1.1.1|?>>
-    <associate|term declaration|<tuple|1.1|?>>
+    <associate|term declaration|<tuple|assignment|?>>
     <associate|term definition|<tuple|declaration<label|term declaration>|?>>
     <associate|term enumeration|<tuple|definition<label|term definition>|?>>
     <associate|term escape_sequence|<tuple|enumeration<label|term
     <associate|term definition|<tuple|declaration<label|term declaration>|?>>
     <associate|term enumeration|<tuple|definition<label|term definition>|?>>
     <associate|term escape_sequence|<tuple|enumeration<label|term