luc038.c (624B)
1 /* Write a program to generate all Pythagorean Triplets with slide 2 length less than or equal to 30. */ 3 /* Let Us C, Chap- 6, Page - 106, Qn No.: B(e) */ 4 5 #include <stdio.h> 6 #include <math.h> 7 8 int main() 9 { 10 int a, b, c; 11 printf("Pythagorean Triplets with slide length less than or equal to 30 : \n"); 12 for (a = 1; a <= 30; a++) 13 { 14 for (b = a; b <= 30; b++) 15 { 16 int c_square = a * a + b * b; 17 for (c = b + 1; c <= 30; c++) 18 { 19 if (c * c == c_square) 20 printf("(%d, %d, %d)\n", a, b, c); 21 } 22 } 23 } 24 return 0; 25 }