VTech E Power User Manual Page 40

  • Download
  • Add to my manuals
  • Print
  • Page
    / 88
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 39
36
Type this:
10 PRINT 3+11/7 press ENTER
RUN
Is it really evaluated from left to right? Yes, but was it the answer you were expecting?
If the answer came out to 4.57143, the computer first divided 11 by 7 getting 1.57143 and
then it added 3 to the result giving 4.57143. You probably were expecting the answer
to be 2 because 3+11 is 14, then divided by 7 is 2.
You can see that expressions are not simply evaluated from left to right. It is necessary
to have an exact set of rules to follow.
Here they are:
Functions Order in which they are performed
( ) things in parentheses (1
st
)
^ raising to a power (2
nd
)
* / multiplication and division (3
rd
)
+ - addition and subtraction (4
th
)
The computer will always look at an expression in parentheses first and follows those
commands. It could be an expression or more sets of brackets. Among the expression,
raising to a power is calculated first, followed by multiplication and division from left to right,
followed by addition and subtraction from left to right. If you’re not sure how the computer
will evaluate the expression, simply put brackets around the expression you want computed
first. Remember the brackets must always be in pairs, one right bracket for each left one.
If you don’t use both brackets, you will receive a “? SYNTAX ERROR message.
NUMERIC VARIABLES
You have seen how you can use BASIC to print numbers and messages. You can also
give values to a BASIC program yourself. The computer uses a letter to stand for a value.
This is called a variable. For example LET D = 609. This statement puts the value 609
into a memory box called “D.”
Try this. Type:
10 LET A=8 press ENTER
Page view 39
1 2 ... 35 36 37 38 39 40 41 42 43 44 45 ... 87 88

Comments to this Manuals

No comments