/* THREE POSITIVE INTEGERS a,b,c FORM A TRIPLET OF a^2 + b^2 = c^2. WRITE A C PROGRAM TO FIND ALL PYTHOGOREAN TRIPLETS a,b,c WHERE a,b < 120.
*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c2,c;
clrscr();
printf("Pythogorean Triplets\n\n");
for(a=1;a<120;a++)
{
for(b=a;b<120;b++)
{
c2 = a*a + b*b;
c=(int)sqrt(c2);
if(c*c == c2)
{
printf("%d %d %d,\t",a,b,c);
}
}
}
getch();
}
/*
=====OUT PUT=====
Pythogorean Triplets
3 4 5, 5 12 13, 6 8 10, 7 24 25, 8 15 17,
9 12 15, 9 40 41, 10 24 26, 11 60 61, 12 16 20,
12 35 37, 13 84 85, 14 48 50, 15 20 25, 15 36 39,
15 112 113, 16 30 34, 16 63 65, 18 24 30, 18 80 82,
20 21 29, 20 48 52, 20 99 101, 21 28 35, 21 72 75,
24 32 40, 24 45 51, 24 70 74, 25 60 65, 27 36 45,
28 45 53, 28 96 100, 30 40 50, 30 72 78, 32 60 68,
33 44 55, 33 56 65, 35 84 91, 36 48 60, 36 77 85,
36 105 111, 39 52 65, 39 80 89, 40 42 58, 40 75 85,
40 96 104, 42 56 70, 44 117 125, 45 60 75, 45 108 117,
48 55 73, 48 64 80, 48 90 102, 51 68 85, 54 72 90,
56 90 106, 56 105 119, 57 76 95, 60 63 87, 60 80 100,
60 91 109, 63 84 105, 65 72 97, 66 88 110, 66 112 130,
69 92 115, 72 96 120, 75 100 125, 78 104 130, 80 84 116,
81 108 135, 84 112 140, 87 116 145, 88 105 137, 96 110 146,
100 105 145,
*/
No comments:
Post a Comment