Casio CFX-9800G-w Owners Manual - Page 171
Casio CFX-9800G-w - Color Graphing Calculator Manual
UPC - 079767128685
View all Casio CFX-9800G-w manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 171 highlights
'About Conditional Jumps With a conditional jump you set up certain criteria and control whether or not the jump is actually performed. Look at the following format. a. If true Left side Relational operator Right s' ide Statemt ent : Statement If not true As shown above, if the condition defined by the relational operator is true, the statement following " " is executed, and then the next statement is executed. If the condition is false, the statement following is skipped, - The following are the conditions that you can define using the relational operators. L = True when L and R are equal; false when L and R are not equal L R True when L and R are not equal; false when L and R are equal L> R True when L is greater than R; false when L is less than or equal to R L,-A, A, =, 0, Goto, 2, : , A, +, B B, Goto, 1, :, Lbl, 2, :, B 31 bytes With this program, 0 is assigned to value memory B to clear it. The next statement prompts for input of a value to value memory A. The next statement is a conditional jump that says: "if the value input for A equals 0, then go to label 2". The statement following label 2 (Lbl 2) ends program execution with a display of the value memory B contents. For other values, the next statement adds value memories A and B, and then stores the result in value memory B again. After this, program execution returns to the statement following label 1 (Lbl 1), where the next input for A is prompted. -306- •About Count Jumps There are two count jumps: one that increments a value memory (Isz) and one that decrements a value memory (Dsz). Look at the following formal Memory contents %0 Cil Isz Memory name : Statement Statement Memory contents = 0 Memory contents 40 I Dsz Memory name : Statement a . Statement Memory contents = 0 As shown above, if the increment or decrement operation. does 'not cause the content of the value memory to become 0, the statement following the value memory name is executed. If the content of the value memory becomes 0, the next statement is skipped. • To use a count jump Example 1 To write a program that accepts input of 10 values, and then calculates the average of the values. Program 1, 0, A, :,0, C, : , Dsz, A; :, Goto, 1, :, C, + , 1, 0 32 bytes This program starts out by assigning a value of 10 to A. This is because value memory A will be used as a control variable. The next statement clears C to zero. After defining the location of label 1 (Lbl 1), the program then prompts for input of a value for B. The next statement adds the value of B to value memory C, and then stores the result in C. The next three statements say: "decrement the value in A, and if it is still greater than 0, jump back to label 1; otherwise divide the contents of C by 10". Example 2 To write a program that calculates at 1-second intervals the altitude of a ball thrown into the air atan initial velocity of Vm/sec and an angle of, S°. The formula is expressed as: h=lbsinSt --;igt2, with g =9.8. The effects of air resistance should be disregarded. Program Deg, :, 0, T, : ,?, V, :, ?, -',S, Lbl, 1, :, Isz, T, :, V, x, sin, S, x, T, -, 9, •, 8, x , T, x2, , 2, 4, Coto, 1 38 bytes -307- A340087-13