Hello!
I am having a problem with my program.I have to write a program that find all pythagorean triples
for side1, side2 and hypotenuse all no longer than 500. I have to use a triple-nested for loop
that tries all posibilities.
I know that the sum of squares to two sides must be equal to the square of hypotenuse.
But the program i have written do not fulfill the above conditions. My program takes input and only checks
the input values. Infact I don't know how to try all posibilities using triple-nested loop.
I am in a need of help.Can any one help? I'll be thankful.

``````#include<iostream.h>
#include<conio.h>
void main()
{
float s1,s2,s3;
double i,j,k;
cout<<"Enter the length of base of triangle: ";
cin>>s1;
cout<<"Enter the length of perpendicular of triangle: ";
cin>>s2;
cout<<"Enter the length of hypotenuse of triangle: ";
cin>>s3;
for(i=1;i<=s1;i++)
{
i=s1;
for(j=1;j<=s2;j++)
j=s2;
for(k=1;k<=s3;k++)
k=s3;
if(s1*s1+s2*s2==s3*s3)
cout<<s1<<", "<<s2<<" and "<<s3<<" sides satisfy the pythogorean triples"<<endl;
else
cout<<"Do not satisfy the puthagorean triples";
}
getch();
}``````

Correct indentation, and proper use of { } in all the places you need them would help.

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.