===========================================================================
CODING
#include<all.h>
void main()
{
clrscr();
int H,s1,s2,i,q,w;
cout<<"Enter The number till where you want to see all the phythagorous triplets: ";
cin>>H;
for(w=1;w<=H;w++)
{
for(i=1;i<w;i++)
{
for(q=1;q<=i;q++)
{
if(i*i+q*q==w*w)
{
cout<<"\n"<<q<<"² + "<<i<<"² = "<<w<<"²";
}
else;
}
}
}
getch();
}
CODING
#include<all.h>
void main()
{
clrscr();
int H,s1,s2,i,q,w;
cout<<"Enter The number till where you want to see all the phythagorous triplets: ";
cin>>H;
for(w=1;w<=H;w++)
{
for(i=1;i<w;i++)
{
for(q=1;q<=i;q++)
{
if(i*i+q*q==w*w)
{
cout<<"\n"<<q<<"² + "<<i<<"² = "<<w<<"²";
}
else;
}
}
}
getch();
}
===========================================================================
No comments:
Post a Comment