Skip to main content

Featured

functions in Python

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();
}

Comments

Popular Posts