IBM 5110 Basic Introduction page 30

Table of Contents

Advertisement

26
Although the numbers and operators in this expression are the same
as those in the previous example, the parentheses completely change
the order of the operations and the final result.
Now, determine the result of the following expression by entering the
numbers, then pressing the EXECUTE key:
4+(3*(4-2))
The order of the arithmetic operations is: 4-2=2, 3x2=6, and 4
6
=4096.
The display screen shows:
.
~
I,
Figure 5 shows other examples of arithmetic expressions.
This is the Way it
This is the Way
Looks as Arithmetic:
it Looks in BASIC:
This is What it Means:
a+b+c
(A+B+C)/2
First add A, B, and C;
2
divide the sum by 2.
+b+c
a -
A+(B+C)/2
Add Band C, divide the
2
sum by 2; add the result
toA.
3a+4
3* A+4
Multiply A by 3; then
add 4.
3(a+4)
3*(A+4)
Add A and 4; multiply
the sum by 3.
x 2 +7
Xt2+7
Square X and add 7.
(X+7)2
(X+7)t2
Add X and 7; square the
quantity.
(x+1 )2
(X+1)t2/2
Add X and 1; square the
2
quantity; divide the
result by 2.
(x; )
(Xt2/2) *(X+Y)/3
Square X and divide by
(x+y)
2; add X and Y and multiply
3
by the previous result; divide
that result by 3.
Figure 5. Examples of Arithmetic and BASIC Expressions
o
/'
'"
(. II
"'1>\
"LJ'
rf '""
\.)1'
(
. .
)
26
Although the numbers and operators in this expression are the same
as those in the previous example, the parentheses completely change
the order of the operations and the final result.
Now, determine the result of the following expression by entering the
numbers, then pressing the EXECUTE key:
4+(3*(4-2))
The order of the arithmetic operations is: 4-2=2, 3x2=6, and 4
6
=4096.
The display screen shows:
.
~
I,
Figure 5 shows other examples of arithmetic expressions.
This is the Way it
This is the Way
Looks as Arithmetic:
it Looks in BASIC:
This is What it Means:
a+b+c
(A+B+C)/2
First add A, B, and C;
2
divide the sum by 2.
+b+c
a -
A+(B+C)/2
Add Band C, divide the
2
sum by 2; add the result
toA.
3a+4
3* A+4
Multiply A by 3; then
add 4.
3(a+4)
3*(A+4)
Add A and 4; multiply
the sum by 3.
x 2 +7
Xt2+7
Square X and add 7.
(X+7)2
(X+7)t2
Add X and 7; square the
quantity.
(x+1 )2
(X+1)t2/2
Add X and 1; square the
2
quantity; divide the
result by 2.
(x; )
(Xt2/2) *(X+Y)/3
Square X and divide by
(x+y)
2; add X and Y and multiply
3
by the previous result; divide
that result by 3.
Figure 5. Examples of Arithmetic and BASIC Expressions
o
/'
'"
(. II
"'1>\
"LJ'
rf '""
\.)1'
(
. .
)

Advertisement

Table of Contents
loading

Table of Contents