🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

question about triangles

Started by
5 comments, last by Nazrix 22 years, 9 months ago
How can you tell if a shape is a triangle given the lengths of 3 sides? My instructor gave told us to do this: Write a C program that reads in three numbers and determines whether these three numbers represent the sides of a triangle (i.e. the summation of the lengths of any two sides is greater than the length of the third side) but then her test run was like this: Enter the lengths of the three sides of a triangle: 30 4 5 The numbers you entered do not represent a triangle. It seems like from what she said about triangles that would be a triangle...I must be missing something
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
Advertisement
The question is wrong. "The summation of the lengths of any two sides is greater than the length of the third side" is not the definition of a triangle at all! It has nothing to do with triangles!

The lengths of the sides of a triangle can be written like this: a2 = b2 + c2

There''s no way that you can put 30, 4 and 5 in the above equation in such a way that the left side equals the right. 3, 4, 5 you can.

codeka.com - Just click it.
quote: Original post by Dean Harding
The question is wrong. "The summation of the lengths of any two sides is greater than the length of the third side" is not the definition of a triangle at all! It has nothing to do with triangles!

The lengths of the sides of a triangle can be written like this: a2 = b2 + c2

There's no way that you can put 30, 4 and 5 in the above equation in such a way that the left side equals the right. 3 , 4, 5 you can.

codeka.com - Just click it.


I thought a2 = b2 + c2 only applied to right triangles?

Edited by - Nazrix on September 13, 2001 7:48:49 PM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
Nazrix? In the math forum?

Anyway, the stuff about any two sides blah blah sounds correct to me. Because they say *any* two sides, you must consider all combinations of sides, and if even one combination fails, you don''t have a triangle. The fact that 4 + 5 is not greater than 30 is why your example fails the test.
quote: Original post by Eric
Nazrix? In the math forum?


the reason was I was questioning her definition of a triangle


quote:
Anyway, the stuff about any two sides blah blah sounds correct to me. Because they say *any* two sides, you must consider all combinations of sides, and if even one combination fails, you don't have a triangle. The fact that 4 + 5 is not greater than 30 is why your example fails the test.



crap! you're right...I was thinking all wrong
Sorry I'm a dumbass today

I guess that's what I get for trying to do homework while at work

A CRPG in development...

Need help? Well, go FAQ yourself.


Edited by - Nazrix on September 13, 2001 8:02:43 PM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi
To put the question to rest permanently (for our friend Dean, who apparently was sleeping that day in math class), yes, the "two side lengths sum greater than third side length" IS indeed a correct definition of a triangle.

For a triangle with lengths a,b, and c,(with lengths being absolute values and no negatives allowed) ALL of the following must be true in order for it to be a triangle:

a+b>c
a+c>b
b+c>a

This is a common homework problem for computer programming classes, it has been used for as long as computer programming classes have (i remember having to solve this problem 12 years ago in Basic 1 class--its when i learned this definition of a triangle).


Get off my lawn!

quote: Original post by TANSTAAFL
To put the question to rest permanently (for our friend Dean, who apparently was sleeping that day in math class), yes, the "two side lengths sum greater than third side length" IS indeed a correct definition of a triangle.

For a triangle with lengths a,b, and c,(with lengths being absolute values and no negatives allowed) ALL of the following must be true in order for it to be a triangle:

a+b>c
a+c>b
b+c>a

This is a common homework problem for computer programming classes, it has been used for as long as computer programming classes have (i remember having to solve this problem 12 years ago in Basic 1 class--its when i learned this definition of a triangle).





Thanks...yeah I was thinking it had to be one of those conditions to be a triangle mostly 'cause I was doing this while at work taking tech support calls and not giving it proper attention



A CRPG in development...

Need help? Well, go FAQ yourself.


Edited by - Nazrix on September 13, 2001 8:29:06 PM
Need help? Well, go FAQ yourself. "Just don't look at the hole." -- Unspoken_Magi

This topic is closed to new replies.

Advertisement