
September 27th, 2014, 05:56 PM
#1
Pythagorean triples in code c, help!
I need to create a code in c fits the description below, I have no idea what to do, if someone could possibly write a code or explain to me what I could do that would be appreciated!
Description
A positive integer triple (a, b, c) with 0 < a < b < c and a^2 + b^2 = c^2
is called a Pythagorean triple. Write a
program in C which reads an integer N and prints
1. the total number of Pythagorean triples (a, b, c) with c < N,
2. every such Pythagorean triple, and
3. the triple that has the largest value of c.
Hint: you can enumerate all possible pairs (a, b) with 0 < a < b < N and check if they satisfy a
2+b
2 < N2
.
Example Input/Output
• Enter a positive integer: [3]
There is no Pythagorean triple in this range.
• Enter a positive integer: [15]
There are 3 Pythagorean triples in this range:
(3, 4, 5)
(5, 12, 13)
(6, 8, 10)
The triple with the largest value of c is (5, 12, 13).
• Enter a positive integer: [6]
There are 1 Pythagorean triples in this range:
(3, 4, 5)
The triple with the largest value of c is (3, 4, 5).

September 28th, 2014, 04:30 AM
#2
Re: Pythagorean triples in code c, help!
This seems like a homework assignment. Please see http://forums.codeguru.com/showthrea...orkassignment
With what exactly are you having difficulty? You are given a good description of the problem. Just saying you have no idea isn't really going to illicit much help as nobody here is going to do your homework assignment for you.
First think about how you would solve this problem using pen and paper. Then design the program from this, code it and finally test and debug it. Once you have produced some code if you post it here we;ll provide further advice and guidance.
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!
