GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 30-Jan-2008, 07:07
jvs1987 jvs1987 is offline
New Member
 
Join Date: Jan 2008
Posts: 3
jvs1987 is on a distinguished road

Whether given 3 numbers form the side of a triangle


pls help the logic behind how to find whether given 3 numbers form the side of a triangle....kindly explain the logic....
  #2  
Old 30-Jan-2008, 08:05
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 6,153
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: pls help..how to find whether given numbers form side of a triangle


Quote:
Originally Posted by jvs1987
...whether given 3 numbers form the side of a triangle...

I think the problem statement might be something like:

Given three positive integers, how can you know whether it is possible to make a triangle with sides whose lengths are equal to those three values?
(Or something like that.)

If this is not the problem, then tell us what it is.

If this is the problem (or something like that), then consider that each side of a triangle must be less than the sum of the other two sides.

If you accept that truth, then you can eliminate any set of three positive integers for which one value is greater than or equal to the sum of the other two, so you can test the following three expressions

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

If any one of them is true, then the three numbers can't be lengths of the sides of a triangle, right?

Now if all of those are false (for a given set of positive integers a, b, c), can you say for sure that it is possible to make a triangle whose sides are those values? (This is a geometry question, not a programming question.)


If you can say that, then just create a program that uses tests for those three expressions. (Or their logical inverses.)

Regards,

Dave
Last edited by davekw7x : 30-Jan-2008 at 08:53.
  #3  
Old 30-Jan-2008, 08:14
jvs1987 jvs1987 is offline
New Member
 
Join Date: Jan 2008
Posts: 3
jvs1987 is on a distinguished road

Re: pls help..how to find whether given numbers form side of a triangle


hey thanks for that.....i was able to solve it....
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
loop to find only odd numbers Avalanche C++ Forum 3 05-Aug-2007 13:02
Help on homework! kemmal C Programming Language 1 06-Nov-2006 11:22
Linear Search eccoflame C Programming Language 3 19-Apr-2005 08:36
Program that will find the first 4 perfect numbers????? bicknell83 C Programming Language 3 30-Mar-2005 01:35

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:51.


vBulletin, Copyright © 2000 - 2014, Jelsoft Enterprises Ltd.