# HP Forums

Full Version: (71B) Right Triangle Solver
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Right Triangle Solver

The program RIGHTTRI is a solver for the sides A, B, and C. To solve for the third side, the desired side needs to have a 0 value, while the other two sides have non-zero values. Each time a solution is found, the values of A, B, and C are reset (set to 0).

Program RIGHTTRI
502 Bytes, 12/22/2016

Code:
```10 DESTROY A,B,C,Z\$ 11 ! LOOP 12 DISP “A, B, C, Solve, Exit” 14 DELAY 0, 0 16 Z\$ = KEY\$ 18 IF Z\$ = “A” THEN 30 20 IF Z\$ = “B” THEN 40 22 IF Z\$ = “C” THEN 50 24 IF Z\$ = “S” THEN 60 26 IF Z\$ = “E” THEN 96 28 GOTO 12 30 INPUT “A = “; A 32 GOTO 12 40 INPUT “B = “; B 42 GOTO 12 50 INPUT “C = “; C 52 GOTO 12 60 IF A=0 AND B AND C THEN 62 ELSE 70 62 S=SQR(C^2-B^2) @ Z\$ = “A” 64 GOTO 90 70 IF A AND B=0 AND C THEN 72 ELSE 80 72 S=SQR(C^2-A^2) @ Z\$ = “B” 74 GOTO 90 80 IF A AND B AND C=0 THEN 82 ELSE 86 82 S=SQR(A^2+B^2) @ Z\$ = “C” 84 GOTO 90 86 DISP “MUST HAVE ONE 0” @ BEEP @ WAIT .5 88 GOTO 10 90 DISP Z\$; “ = “; S @ PAUSE 92 GOTO 10 94 DISP “DONE”```

Notes:

The line of IF A=0 AND B AND C… tests whether A is zero, B and C are non-zero. You can test whether a variable is non-zero by just typing the variable in an IF condition.

The function SQR is the square root function of the HP 71B.

Anything following an exclamation point (!) is a comment.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :