Featured
- Get link
- X
- Other Apps
c++ program to print pythagorean triples
/*Following program prints pyhtagorean triplets from 1 upto the number entered by user*/
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int x,y,z,lim;
cout<<"enter the limit\n";
cin>>lim;
for(x=3;x<=lim;x++)
{
for(y=2;y<x;y++)
{
for(z=1;z<y;z++)
{
if(x*x==y*y+z*z)
{
cout<<"\nPythagorean Triplet\n";
cout<<z<<" "<<y<<" "<<x<<endl;
}
}
}
}
getch();
}
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int x,y,z,lim;
cout<<"enter the limit\n";
cin>>lim;
for(x=3;x<=lim;x++)
{
for(y=2;y<x;y++)
{
for(z=1;z<y;z++)
{
if(x*x==y*y+z*z)
{
cout<<"\nPythagorean Triplet\n";
cout<<z<<" "<<y<<" "<<x<<endl;
}
}
}
}
getch();
}
- Get link
- X
- Other Apps
Labels:
C program to display Pythagorean triplets
C++ program to print pythagoran triplets between 1 to 1000
c++ program to print pythagorean triples
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment