PROGRAM
Write a program to determine al Pythagorean triplets in the range 10 to 100. (A Pythagorean triplets is a set of three integers i, j, k such that i2+j2=k2)#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
long int side1, side2, hyp;
clrscr();
cout<< " \n Pythagorean triples between 100 to 1000:\n\n ";
for( side1 = 100; side1<=1000 ; side1 ++)
for( side2 = 100; side2<=1000 ; side2 ++)
for( hyp = 100; hyp<=1000 ; hyp ++)
if(((side1*side1) + (side2*side2))==(hyp*hyp))
cout<< "\n"<<"("<<side1<<"\t"<< side2<<"\t"<<hyp<<")";
getch();
}
========================================================================
OUTPUT:-
Sample run between 1 to 10
Pythagorean triples between 1 to 10:
(3 4 5)
(4 3 5)
(6 8 10)
(8 6 10)
========================================================================
No comments:
Post a Comment