1 .\" $FreeBSD: head/share/doc/usd/06.bc/bc 282235 2015-04-29 16:41:48Z bapt $
2 .\" $OpenBSD: bc,v 1.9 2004/07/09 10:23:05 jmc Exp $
4 .\" Copyright (C) Caldera International Inc. 2001-2002.
5 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code and documentation must retain the above
11 .\" copyright notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed or owned by Caldera
18 .\" International, Inc.
19 .\" 4. Neither the name of Caldera International, Inc. nor the names of other
20 .\" contributors may be used to endorse or promote products derived from
21 .\" this software without specific prior written permission.
23 .\" USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
24 .\" INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
25 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 .\" IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT,
28 .\" INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 .\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
33 .\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 .\" POSSIBILITY OF SUCH DAMAGE.
36 .\" @(#)bc 6.2 (Berkeley) 4/17/91
42 .EH 'USD:6-%''BC \- An Arbitrary Precision Desk-Calculator Language'
43 .OH 'BC \- An Arbitrary Precision Desk-Calculator Language''USD:6-%'
47 BC \- An Arbitrary Precision Desk-Calculator Language
55 BC is a language and a compiler for doing arbitrary precision arithmetic
56 on the PDP-11 under the
59 system. The output of the compiler is interpreted and executed by
60 a collection of routines which can input, output, and do
61 arithmetic on indefinitely large integers and on scaled fixed-point
64 These routines are themselves based on a dynamic storage allocator.
65 Overflow does not occur until all available core storage
68 The language has a complete control structure as well as immediate-mode
69 operation. Functions can be defined and saved for later execution.
71 Two five hundred-digit numbers can be multiplied to give a
72 thousand digit result in about ten seconds.
74 A small collection of library functions is also available,
75 including sin, cos, arctan, log, exponential, and Bessel functions of
78 Some of the uses of this compiler are
80 to do computation with large integers,
82 to do computation accurate to many decimal places,
84 conversion of numbers from one base to another base.
90 BC is a language and a compiler for doing arbitrary precision
93 time-sharing system [1].
94 The compiler was written to make conveniently available a
95 collection of routines (called DC [5]) which are capable of doing
96 arithmetic on integers of arbitrary size. The compiler
97 is by no means intended to provide a complete programming
99 It is a minimal language facility.
101 There is a scaling provision that permits the
102 use of decimal point notation.
103 Provision is made for input and output in bases other than
104 decimal. Numbers can be converted from decimal to octal by
105 simply setting the output base to equal 8.
107 The actual limit on the number of digits that can
108 be handled depends on the amount of storage available on the machine.
109 Manipulation of numbers with many hundreds of digits
110 is possible even on the smallest versions of
113 The syntax of BC has been deliberately selected to agree
114 substantially with the C language [2]. Those who
115 are familiar with C will find few surprises in this language.
117 Simple Computations with Integers
119 The simplest kind of statement is an arithmetic expression
121 For instance, if you type in the line:
127 the program responds immediately with the line
133 The operators \-, *, /, %, and ^ can also be used; they
134 indicate subtraction, multiplication, division, remaindering, and
135 exponentiation, respectively. Division of integers produces an
136 integer result truncated toward zero.
137 Division by zero produces an error
140 Any term in an expression may be prefixed by a minus sign to
141 indicate that it is to be negated (the `unary' minus sign).
148 is interpreted to mean that \-3 is to be added to 7.
150 More complex expressions with several operators and with
151 parentheses are interpreted just as in
152 Fortran, with ^ having the greatest binding
153 power, then * and % and /, and finally + and \-.
154 Contents of parentheses are evaluated before material
155 outside the parentheses.
157 performed from right to left and the other operators
165 are equivalent, as are the two expressions
171 BC shares with Fortran and C the undesirable convention that
173 \fBa/b*c\fP is equivalent to \fB(a/b)*c\fP
177 Internal storage registers to hold numbers have single lower-case
178 letter names. The value of an expression can be assigned to
179 a register in the usual way. The statement
185 has the effect of increasing by three the value of the contents of the
187 When, as in this case, the outermost operator is an =, the
188 assignment is performed but the result is not printed.
189 Only 26 of these named storage registers are available.
191 There is a built-in square root function whose
192 result is truncated to an integer (but see scaling below).
200 produce the printed result
209 There are special internal quantities, called `ibase' and `obase'.
210 The contents of `ibase', initially set to 10,
211 determines the base used for interpreting numbers read in.
212 For example, the lines
219 will produce the output line
225 and you are all set up to do octal to decimal conversions.
226 Beware, however of trying to change the input base back
233 Because the number 10 is interpreted as octal, this statement will
235 For those who deal in hexadecimal notation,
236 the characters A\-F are permitted in numbers
237 (no matter what base is in effect)
239 interpreted as digits having values 10\-15 respectively.
246 will change you back to decimal input base no matter what the
247 current input base is.
248 Negative and large positive input bases are
249 permitted but useless.
250 No mechanism has been provided for the input of arbitrary
251 numbers in bases less than 1 and greater than 16.
253 The contents of `obase', initially set to 10, are used as the base for output
261 will produce the output line
267 which is to be interpreted as a 3-digit hexadecimal number.
268 Very large output bases are permitted, and they are sometimes useful.
269 For example, large numbers can be output in groups of five digits
270 by setting `obase' to 100000.
271 Strange (i.e. 1, 0, or negative) output bases are
272 handled appropriately.
274 Very large numbers are split across lines with 70 characters per line.
275 Lines which are continued end with \\.
276 Decimal output conversion is practically instantaneous, but output
277 of very large numbers (i.e., more than 100 digits) with other bases
279 Non-decimal output conversion of
280 a one hundred digit number takes about
283 It is best to remember that `ibase' and `obase' have no effect
284 whatever on the course of internal computation or
285 on the evaluation of expressions, but only affect input and
286 output conversion, respectively.
290 A third special internal quantity called `scale' is
291 used to determine the scale of calculated
294 up to a specific number of decimal digits after the decimal point.
295 This fractional part is retained in further computations.
296 We refer to the number of digits after the decimal point of
297 a number as its scale.
298 The current implementation allows scales to be as large as can be
299 represented by a 32-bit unsigned number minus one.
300 This is a non-portable extension.
301 The original implementation allowed for a maximum scale of 99.
303 When two scaled numbers are combined by
304 means of one of the arithmetic operations, the result
305 has a scale determined by the following rules. For
306 addition and subtraction, the scale of the result is the larger
307 of the scales of the two operands. In this case,
308 there is never any truncation of the result.
309 For multiplications, the scale of the result is never
310 less than the maximum of the two scales of the operands,
311 never more than the sum of the scales of the operands
312 and, subject to those two restrictions,
313 the scale of the result is set equal to the contents of the internal
315 The scale of a quotient is the contents of the internal
316 quantity `scale'. The scale of a remainder is
317 the sum of the scales of the quotient and the divisor.
318 The result of an exponentiation is scaled as if
319 the implied multiplications were performed.
320 An exponent must be an integer.
321 The scale of a square root is set to the maximum of the scale
322 of the argument and the contents of `scale'.
324 All of the internal operations are actually carried out in terms
325 of integers, with digits being discarded when necessary.
326 In every case where digits are discarded, truncation and
327 not rounding is performed.
330 `scale' must be no greater than
331 4294967294 and no less than 0. It is initially set to 0.
333 The internal quantities `scale', `ibase', and `obase' can be
334 used in expressions just like other variables.
341 increases the value of `scale' by one, and the line
347 causes the current value of `scale' to be printed.
349 The value of `scale' retains its meaning as a
350 number of decimal digits to be retained in internal
351 computation even when `ibase' or `obase' are not equal to 10.
352 The internal computations (which are still conducted in decimal,
353 regardless of the bases) are performed to the specified number
354 of decimal digits, never hexadecimal or octal or any
355 other kind of digits.
359 The name of a function is a single lower-case letter.
360 Function names are permitted to collide with simple
362 Twenty-six different defined functions are permitted
363 in addition to the twenty-six variable names.
370 begins the definition of a function with one argument.
371 This line must be followed by one or more statements,
372 which make up the body of the function, ending
373 with a right brace }.
374 Return of control from a function occurs when a return
375 statement is executed or when the end of the function is reached.
376 The return statement can take either
384 In the first case, the value of the function is 0, and in
385 the second, the value of the expression in parentheses.
387 Variables used in the function can be declared as automatic
388 by a statement of the form
394 There can be only one `auto' statement in a function and it must
395 be the first statement in the definition.
396 These automatic variables are allocated space and initialized
397 to zero on entry to the function and thrown away on return. The
398 values of any variables with the same names outside the function
400 Functions may be called recursively and the automatic variables
401 at each level of call are protected.
402 The parameters named in a function definition are treated in
403 the same way as the automatic variables of that function
404 with the single exception that they are given a value
405 on entry to the function.
406 An example of a function definition is
416 The value of this function, when called, will be the
420 A function is called by the appearance of its name
421 followed by a string of arguments enclosed in
422 parentheses and separated by commas.
424 is unpredictable if the wrong number of arguments is used.
426 Functions with no arguments are defined and called using
427 parentheses with nothing between them: b().
433 above has been defined, then the line
439 would cause the result 21.98 to be printed and the line
445 would cause the value of x to become 60.
447 Subscripted Variables
449 A single lower-case letter variable name
450 followed by an expression in brackets is called a subscripted
451 variable (an array element).
452 The variable name is called the array name and the expression
453 in brackets is called the subscript.
454 Only one-dimensional arrays are
455 permitted. The names of arrays are permitted to
456 collide with the names of simple variables and function names.
458 part of a subscript is discarded before use.
459 Subscripts must be greater than or equal to zero and
460 less than or equal to 2047.
462 Subscripted variables may be freely used in expressions, in
463 function calls, and in return statements.
465 An array name may be used as an argument to a function,
466 or may be declared as automatic in
467 a function definition by the use of empty brackets:
475 When an array name is so used, the whole contents of the array
476 are copied for the use of the function, and thrown away on exit
478 Array names which refer to whole arrays cannot be used
479 in any other contexts.
483 The `if', the `while', and the `for' statements
484 may be used to alter the flow within programs or to cause iteration.
485 The range of each of them is a statement or
486 a compound statement consisting of a collection of
487 statements enclosed in braces.
488 They are written in the following way
491 if(relation) statement
492 if(relation) statement else statement
493 while(relation) statement
494 for(expression1; relation; expression2) statement
500 if(relation) {statements}
501 if(relation) {statements} else {statements}
502 while(relation) {statements}
503 for(expression1; relation; expression2) {statements}
507 A relation in one of the control statements is an expression of the form
513 where two expressions are related by one of the six relational
514 operators `<', `>', `<=', `>=', `==', or `!='.
516 stands for `equal to' and `!=' stands for `not equal to'.
517 The meaning of the remaining relational operators is
520 BEWARE of using `=' instead of `==' in a relational. Unfortunately,
521 both of them are legal, so you will not get a diagnostic
522 message, but `=' really will not do a comparison.
524 The `if' statement causes execution of its range
525 if and only if the relation is true.
526 Then control passes to the next statement in sequence.
527 If an `else' branch is present, the statements in this branch are
528 executed if the relation is false.
529 The `else' keyword is a non-portable extension.
531 The `while' statement causes execution of its range
532 repeatedly as long as the relation
533 is true. The relation is tested before each execution
534 of its range and if the relation
535 is false, control passes to the next statement beyond the range
538 The `for' statement begins
539 by executing `expression1'. Then the relation is tested
540 and, if true, the statements in the range of the `for' are executed.
541 Then `expression2' is executed. The relation is tested, and so on.
542 The typical use of the `for' statement is for a controlled iteration,
546 for(i=1; i<=10; i=i+1) i
549 which will print the integers from 1 to 10.
550 Here are some examples of the use of the control statements.
556 for(i=1; i<=n; i=i+1) x=x*i
575 is a positive integer.
576 Here is the definition of a function which will
577 compute values of the binomial coefficient
578 (m and n are assumed to be positive integers).
584 for(j=1; j<=m; j=j+1) x=x*(n\-j+1)/j
589 The following function computes values of the exponential function
590 by summing the appropriate series
591 without regard for possible truncation errors:
616 There are some language features that every user should know
617 about even if he will not use them.
619 Normally statements are typed one to a line. It is also permissible
620 to type several statements on a line separated by semicolons.
622 If an assignment statement is parenthesized, it then has
623 a value and it can be used anywhere that an expression can.
624 For example, the line
630 not only makes the indicated assignment, but also prints the
633 Here is an example of a use of the value of an
634 assignment statement even when it is not parenthesized.
640 causes a value to be assigned to x and also increments i
641 before it is used as a subscript.
643 The following constructs work in BC in exactly the same manner
644 as they do in the C language. Consult the appendix or the
645 C manuals [2] for their exact workings.
649 x=y=z is the same as x=(y=z)
662 Even if you don't intend to use the constructs,
663 if you type one inadvertently, something correct but unexpected
666 Three Important Things
668 1. To exit a BC program, type `quit'.
670 2. There is a comment convention identical to that of C and
671 of PL/I. Comments begin with `/*' and end with `*/'.
672 As a non-portable extension, comments may also start with a `#' and end with
674 The newline is not part of the comment.
676 3. There is a library of math functions which may be obtained by
677 typing at command level
683 This command will load a set of library functions
684 which, at the time of writing, consists of sine (named `s'),
685 cosine (`c'), arctangent (`a'), natural logarithm (`l'),
686 exponential (`e') and Bessel functions of integer order (`j(n,x)'). Doubtless more functions will be added
688 The library sets the scale to 20. You can reset it to something
690 The design of these mathematical library routines
691 is discussed elsewhere [3].
699 BC will read and execute the named file or files before accepting
700 commands from the keyboard. In this way, you may load your
701 favorite programs and function definitions.
705 The compiler is written in YACC [4]; its original
706 version was written by S. C. Johnson.
710 K. Thompson and D. M. Ritchie,
712 UNIX Programmer's Manual,
720 The C Programming Language,
726 A Library of Reference Standard Mathematical Subroutines,
728 Bell Laboratories internal memorandum, 1975.
732 YACC \(em Yet Another Compiler-Compiler.
734 Bell Laboratories Computing Science Technical Report #32, 1978.
736 R. Morris and L. L. Cherry,
738 DC \- An Interactive Desk Calculator.
750 In the following pages syntactic categories are in \fIitalics\fP;
751 literals are in \fBbold\fP; material in brackets [\|] is optional.
755 Tokens consist of keywords, identifiers, constants, operators,
757 Token separators may be blanks, tabs or comments.
758 Newline characters or semicolons separate statements.
762 Comments are introduced by the characters /* and terminated by
764 As a non-portable extension, comments may also start with a # and
766 The newline is not part of the comment.
770 There are three kinds of identifiers \- ordinary identifiers, array identifiers
771 and function identifiers.
772 All three types consist of single lower-case letters.
773 Array identifiers are followed by square brackets, possibly
774 enclosing an expression describing a subscript.
775 Arrays are singly dimensioned and may contain up to 2048
777 Indexing begins at zero so an array may be indexed from 0 to 2047.
778 Subscripts are truncated to integers.
779 Function identifiers are followed by parentheses, possibly enclosing arguments.
780 The three types of identifiers do not conflict;
781 a program can have a variable named \fBx\fP,
782 an array named \fBx\fP and a function named \fBx\fP, all of which are separate and
787 The following are reserved keywords:
805 Constants consist of arbitrarily long numbers
806 with an optional decimal point.
807 The hexadecimal digits \fBA\fP\-\fBF\fP are also recognized as digits with
808 values 10\-15, respectively.
812 The value of an expression is printed unless the main
813 operator is an assignment.
814 The value printed is assigned to the special variable \fBlast\fP.
815 A single dot may be used as a synonym for \fBlast\fP.
816 This is a non-portable extension.
817 Precedence is the same as the order
818 of presentation here, with highest appearing first.
819 Left or right associativity, where applicable, is
820 discussed with each operator.
823 Primitive expressions
827 Named expressions are
828 places where values are stored.
830 named expressions are legal on the left
831 side of an assignment.
832 The value of a named expression is the value stored in the place named.
836 Simple identifiers are named expressions.
837 They have an initial value of zero.
839 \fIarray-name\fP\|[\|\fIexpression\fP\|]
841 Array elements are named expressions.
842 They have an initial value of zero.
844 \fBscale\fR, \fBibase\fR and \fBobase\fR
846 The internal registers
847 \fBscale\fP, \fBibase\fP and \fBobase\fP are all named expressions.
848 \fBscale\fP is the number of digits after the decimal point to be
849 retained in arithmetic operations.
850 \fBscale\fR has an initial value of zero.
851 \fBibase\fP and \fBobase\fP are the input and output number
853 Both \fBibase\fR and \fBobase\fR have initial values of 10.
857 \fIfunction-name\fB\|(\fR[\fIexpression\fR\|[\fB,\|\fIexpression\|\fR.\|.\|.\|]\|]\fB)
859 A function call consists of a function name followed by parentheses
860 containing a comma-separated list of
861 expressions, which are the function arguments.
862 A whole array passed as an argument is specified by the
863 array name followed by empty square brackets.
864 All function arguments are passed by
866 As a result, changes made to the formal parameters have
867 no effect on the actual arguments.
868 If the function terminates by executing a return
869 statement, the value of the function is
870 the value of the expression in the parentheses of the return
871 statement or is zero if no expression is provided
872 or if there is no return statement.
874 sqrt\|(\|\fIexpression\fP\|)
876 The result is the square root of the expression.
877 The result is truncated in the least significant decimal place.
878 The scale of the result is
879 the scale of the expression or the
886 length\|(\|\fIexpression\fP\|)
888 The result is the total number of significant decimal digits in the expression.
889 The scale of the result is zero.
891 scale\|(\|\fIexpression\fP\|)
893 The result is the scale of the expression.
894 The scale of the result is zero.
898 Constants are primitive expressions.
902 An expression surrounded by parentheses is
903 a primitive expression.
904 The parentheses are used to alter the
914 The result is the negative of the expression.
916 ++\|\fInamed-expression\fP
918 The named expression is
920 The result is the value of the named expression after
923 \-\-\|\fInamed-expression\fP
925 The named expression is
927 The result is the value of the named expression after
930 \fInamed-expression\fP\|++
932 The named expression is
934 The result is the value of the named expression before
937 \fInamed-expression\fP\|\-\-
939 The named expression is
941 The result is the value of the named expression before
944 Exponentiation operator
946 The exponentiation operator binds right to left.
948 \fIexpression\fP ^ \fIexpression\fP
950 The result is the first
951 expression raised to the power of the
953 The second expression must be an integer.
955 is the scale of the left expression
956 and \fIb\fP is the absolute value
957 of the right expression,
958 then the scale of the result is:
960 min\|(\|\fIa\(mub\fP,\|max\|(\|\fBscale\fP,\|\fIa\fP\|)\|)
962 Multiplicative operators
964 The operators *, /, % bind left to right.
966 \fIexpression\fP * \fIexpression\fP
968 The result is the product
969 of the two expressions.
970 If \fIa\fP and \fIb\fP are the
971 scales of the two expressions,
972 then the scale of the result is:
974 min\|(\|\fIa+b\fP,\|max\|(\|\fBscale\fP,\|\fIa\fP,\|\fIb\fP\|)\|)
976 \fIexpression\fP / \fIexpression\fP
978 The result is the quotient of the two expressions.
979 The scale of the result is the value of \fBscale\fR.
981 \fIexpression\fP % \fIexpression\fP
983 The % operator produces the remainder of the division
984 of the two expressions.
986 \fIa\fP%\fIb\fP is \fIa\fP\-\fIa\fP/\fIb\fP*\fIb\fP.
988 The scale of the result is the sum of the scale of
989 the divisor and the value of
996 The additive operators bind left to right.
998 \fIexpression\fP + \fIexpression\fP
1000 The result is the sum of the two expressions.
1001 The scale of the result is
1002 the maximum of the scales of the expressions.
1004 \fIexpression\fP \- \fIexpression\fP
1006 The result is the difference of the two expressions.
1007 The scale of the result is the
1008 maximum of the scales of the expressions.
1010 assignment operators
1012 The assignment operators bind right to left.
1014 \fInamed-expression\fP = \fIexpression\fP
1016 This expression results in assigning the value of the expression
1018 to the named expression on the left.
1020 \fInamed-expression\fP += \fIexpression\fP
1022 \fInamed-expression\fP \-= \fIexpression\fP
1024 \fInamed-expression\fP *= \fIexpression\fP
1026 \fInamed-expression\fP /= \fIexpression\fP
1028 \fInamed-expression\fP %= \fIexpression\fP
1030 \fInamed-expression\fP ^= \fIexpression\fP
1032 The result of the above expressions is equivalent
1033 to ``named expression = named expression OP expression'',
1034 where OP is the operator after the = sign.
1038 Unlike all other operators, the relational operators
1039 are only valid as the object of an \fBif\fP, \fBwhile\fP,
1040 or inside a \fBfor\fP statement.
1042 \fIexpression\fP < \fIexpression\fP
1044 \fIexpression\fP > \fIexpression\fP
1046 \fIexpression\fP <= \fIexpression\fP
1048 \fIexpression\fP >= \fIexpression\fP
1050 \fIexpression\fP == \fIexpression\fP
1052 \fIexpression\fP != \fIexpression\fP
1056 There are only two storage classes in BC, global and automatic
1058 Only identifiers that are to be local to a function need be
1059 declared with the \fBauto\fP command.
1060 The arguments to a function
1061 are local to the function.
1062 All other identifiers are assumed to be global
1063 and available to all functions.
1064 All identifiers, global and local, have initial values
1066 Identifiers declared as \fBauto\fP are allocated on entry to the function
1067 and released on returning from the function.
1068 They therefore do not retain values between function calls.
1069 \fBauto\fP arrays are specified by the array name followed by empty square brackets.
1071 Automatic variables in BC do not work in exactly the same way
1072 as in either C or PL/I. On entry to a function, the old values of
1073 the names that appear as parameters and as automatic
1074 variables are pushed onto a stack.
1075 Until return is made from the function, reference to these
1076 names refers only to the new values.
1080 Statements must be separated by semicolon or newline.
1081 Except where altered by control statements, execution
1084 Expression statements
1086 When a statement is an expression, unless
1087 the main operator is an assignment, the value
1088 of the expression is printed, followed by a newline character.
1092 Statements may be grouped together and used when one statement is expected
1093 by surrounding them with { }.
1095 Quoted string statements
1099 This statement prints the string inside the quotes.
1103 \fBif\|(\|\fIrelation\fB\|)\|\fIstatement\fR
1105 The substatement is executed if the relation is true.
1109 \fBif\|(\|\fIrelation\fB\|)\|\fIstatement\fB\|else\|\fIstatement\fR
1111 The first substatement is executed if the relation is true, the second
1112 substatement if the relation is false.
1113 The \fBif-else\fR statement is a non-portable extension.
1117 \fBwhile\|(\|\fIrelation\fB\|)\|\fIstatement\fR
1119 The statement is executed while the relation
1121 The test occurs before each execution of the statement.
1125 \fBfor\|(\|\fIexpression\fB; \fIrelation\fB; \fIexpression\fB\|)\|\fIstatement\fR
1127 The \fBfor\fR statement is the same as
1131 \fBwhile\|(\fPrelation\|\fB) {\fP
1138 All three expressions may be left out.
1139 This is a non-portable extension.
1145 \fBbreak\fP causes termination of a \fBfor\fP or \fBwhile\fP statement.
1151 \fBcontinue\fP causes the next iteration of a \fBfor\fP or \fBwhile\fP
1152 statement to start, skipping the remainder of the loop.
1153 For a \fBwhile\fP statement, execution continues with the evaluation
1155 For a \fBfor\fP statement, execution continues with evaluation of
1156 the last-expression.
1157 The \fBcontinue\fP statement is a non-portable extension.
1161 \fBauto \fIidentifier\fR\|[\|\fB,\fIidentifier\fR\|]
1163 The \fBauto\fR statement causes the values of the identifiers to be pushed down.
1164 The identifiers can be ordinary identifiers or array identifiers.
1165 Array identifiers are specified by following the array name by empty square
1167 The auto statement must be the first statement
1168 in a function definition.
1173 \fBdefine(\|\fR[\fIparameter\|\fR[\fB\|,\|\fIparameter\|.\|.\|.\|\fR]\|]\|\fB)\|{\fI
1177 The \fBdefine\fR statement defines a function.
1179 be ordinary identifiers or array names.
1180 Array names must be followed by empty square brackets.
1181 As a non-portable extension, the opening brace may also appear on the
1188 \fBreturn(\fI\|expression\|\fB)\fR
1190 The \fBreturn\fR statement causes termination of a function,
1191 popping of its auto variables, and
1192 specifies the result of the function.
1193 The first form is equivalent to \fBreturn(0)\fR.
1194 The result of the function is the result of the expression
1196 Leaving out the expression between parentheses is equivalent to
1198 As a non-portable extension, the parentheses may be left out.
1202 The \fBprint\fR statement takes a list of comma-separated expressions.
1203 Each expression in the list is evaluated and the computed
1204 value is printed and assigned to the variable `last'.
1205 No trailing newline is printed.
1206 The expression may also be a string enclosed in double quotes.
1207 Within these strings the following escape sequences may be used:
1217 for carriage return,
1221 for double quote and
1224 Any other character following a backslash will be ignored.
1225 Strings will not be assigned to `last'.
1226 The \fBprint\fR statement is a non-portable extension.
1230 The \fBquit\fR statement stops execution of a BC program and returns
1231 control to UNIX when it is first encountered.
1232 Because it is not treated as an executable statement,
1234 in a function definition or in an