MPE/iX Shell and Utilities Reference Manual, Vol 1

bc(1) MPE/iX Shell and Utilities bc(1)
while (relation) statement
repeatedly performs the given statement while relation is true. For example,
i=1
a=0
while (i <= 10) {
a+=i
++i
}
adds the integers from 1 through 10 and stores the result in a.
If the relation is not true when bc encounters the while loop, bc does not perform
statement.
print expression , expression ...
displays the results of the expressions. Normally bc displays the value of each expres-
sion or string it encounters. This makes it difficult to format your output in programs.
For this reason, the
MPE/iX Shell and Utilities version of bc has a print statement to
give you more control over how things are displayed. print lets you display several
numbers on the same line with strings. This statement displays all of its arguments on a
single line. A single space is displayed between adjacent numbers (but not between
numbers and strings). A print statement with no arguments displays a newline. If the
last argument is null, subsequent output continues on the same line. Here are some
examples of how to use print:
/* basic print statement */
print "The square of ", 2, "is ", 2*2
The square of 2 is 4
/* inserts a space between adjacent numbers */
print 1,2,3
123
/* note - no spaces */
print 1,"",2,"",3
123
/* just print a blank line */
print
/* two statements with output on same line */
print 1,2,3, ; print 4, 5, 6
123456
Commands and Utilities 1-55