I need help in my assignment,
i get stuck in half way.
Here is the question:
Pythagorean Triples
Some right triangles have sides that are all integers. A set of three integer values for the sides of a right triangle is called a Pythagorean triple. These three sides must satisfy the relationship that the sum of the squares of the two sides is equal to the square of the hypotenuse. Write a program to find all Pythagorean triples for side1, side2, and hypotenuse none larger than 30. Use a triple tested For/Next loop that tries all possibilities. This is an example of “brute force” computing. You will learn in more advanced computer science courses that there are some problems for which there is no known algorithmic approach other than using sheer brute force. .

I having trouble of Calculation , and i want show that is error message if the user key in alphabet.

Thanks!!

First, let's make sure we understand the parameters:

sqrt(aa + bb) <= 30 and a <=30 and b <=30

right?

so start by setting b to 1 and running a from 1 to N
exit the loop when the equation result is > 30
that will give you each of the values of the 1 side when the other side value is 1

now set b to 2 (bb=4) (increase of 1)
start a loop that runs while the result is <= 30
increase b to 3 (bb=9)
again, a will start @ 1

keep doing this until your b value reaches 29
because when b reaches 30 you will not have any valid a
because that will mean you will not have any valid a

make sure to record the valid values of a,b into an array
you could even display the valid values into a textbox

good luck,

eric

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.