Post Reply 
(41C) Area of Triangle (SSS)
11-11-2018, 07:53 AM (This post was last modified: 11-11-2018 08:51 AM by Dieter.)
Post: #5
RE: (41C) Area of Triangle (SSS)
(11-11-2018 05:04 AM)Gamo Wrote:  My program only work when

A ≤ B < C
A = B = C
A ≠ B ≠ C

This means that your example A=8, B=8, C=3 would not work.
In general, according to these rules no isosceles triangle can be entered where the two equal sides are larger than the third one.

You can modify the program so that it will always work when A ≤ B ≤ C.

Still the LBL 02 part should be removed. Take a look at the code:
The program first checks if A=B...

Code:
RCL 01
RCL 02
X=Y
GTO 02

...and if true, it jumps to LBL 02 where the same test is done once again:

Code:
LBL 02
RCL 01
RCL 02
X=Y
GTO 03

Since this always tests true again, the program always continues at LBL 03 (where the program checks if B and C are equal as well):

Code:
LBL 03
RCL 02
RCL 03
X=Y
GTO 04
"ISOSCELES"
PROMPT

That's why "ISOSCELES" appears twice in the program.
So you should remove the complete LBL 02 part and replace the "GTO 02" line with "GTO 03".

BTW, in an HP-41 program quotation marks are used for text. You you should not use them for commands, and vice versa.
So instead of

ISOSCELES
"PROMPT"

you better write

"ISOSCELES"
PROMPT

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(41C) Area of Triangle (SSS) - Gamo - 11-10-2018, 12:20 PM
RE: (41C) Area of Triangle (SSS) - Dieter - 11-10-2018, 08:53 PM
RE: (41C) Area of Triangle (SSS) - Dieter - 11-12-2018, 08:28 PM
RE: (41C) Area of Triangle (SSS) - Gamo - 11-11-2018, 05:04 AM
RE: (41C) Area of Triangle (SSS) - Dieter - 11-11-2018 07:53 AM
RE: (41C) Area of Triangle (SSS) - Gamo - 11-11-2018, 12:23 PM
RE: (41C) Area of Triangle (SSS) - Dieter - 11-11-2018, 04:25 PM



User(s) browsing this thread: 1 Guest(s)