packs the power of several programmable calculators put together, it is as easy to use as a simple four-function calculator. Furthermore, everything you type into it is instantly displayed on the screen, and that makes it easier to keep track of what you are doing. Type: ?((9*8+7*6-5*4)/3)*2 PET says: 62.6666667 To perform arithmetic on your PET, simply tell it in BASIC to print your answer. Note how much it looks like a direct question: Type: ?(9*8+7*6-5*(4/3)1*2 PET says: 214.666667 ? 2 + 2 PET does all the work inside the parentheses first, before it does any- thing outside of them. Once inside parentheses, PET does multiplica tion and division, then addition and subtraction.
After all the work inside the parentheses is done, PET moves outside and does everyt hing" there. When you press the RETURN key. PET prints the result on the screen. Let's look now at some of the arithmetic functions and find out how to use them. First, type NEW, to delete the program we were using. Now, type these program lines: PET arithmetic is not complex or mysterious. But, like human arith- metic, it does have rules. One of the most important rules is the order of operation: 100 FOR I=1to10 120 PRINT I,I*I,SQR(I) 130 NEXT I I . exponentiation t (above RETURN key) 2. multiplication and division * / 3. addition and subtraction +- and RUN. In direct mode, type:
The result represents I (the count or index), I squared (the * means multiply), and the square root of I. SQR(X ) is the Square Root func- tion, and finds the square root of whatever number you put inside the parentheses. Like all BASIC functions, SQR(X) requires an argument any number you choose, enclosed in parentheses. Arithmetic expres sions can be used if you like instead of numbers, like SQR(5*20) ?9*3+7*6-5*4/3*2 PET will respond: 100. 666667 You (because you're the one in charge here) decide how to group the expression so the result will be correct. You do this with parentheses. All the arithmetic functions are used in a similar fashion.
Turn to the BASIC keywords (Appendix II) and find the section on Arithmetic functions. You can check out the way each one works by substituting it for one of the functions in line 1 2Q of the program. The brief description of the function, along with actually trying it yourself, will show you how to use it. Type: ?(9*8+7)*6-5*4/3*2 PET says: 460.666667 Type: ?(9*8+7*6-5)*(4/3*2) www.commodore.ca PET says: 290.666667 Free for personal use but you must have written permission to reproduce 14 25