bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

APC-PRAC-039.c (1076B)


      1 /*
      2  * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025
      3  * Repo: https://github.com/notamitgamer/bsc
      4  * License: MIT
      5  */
      6 
      7 /*
      8 Write a C program to print all unique combinations of three numbers (a, b, c) such that:
      9 1 ≤ a, b, c ≤ 30 and a² + b² = c² (Pythagorean triplets)
     10 */
     11 /* Author: Amit Dutta, Date: 21-11-2025 */
     12 
     13 // This code has not been compiled.
     14 // If you find any issues, please create a new issue on GitHub regarding them.
     15 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
     16 
     17 #include <stdio.h>
     18 
     19 int main()
     20 {
     21     printf("a² + b² = c² :  ");
     22     int i, j, k, sq1, sq2, count = 0;
     23     for (i = 1; i <= 30; i++)
     24     {
     25         sq1 = i * i;
     26         for (j = i + 1; j <= 30; j++)
     27         {
     28             sq2 = j * j;
     29             for (k = j + 1; k <= 30; k++)
     30             {
     31                 if (sq1 + sq2 == k * k)
     32                 {
     33                     printf("(%d, %d, %d)  ", i, j, k);
     34                     count++;
     35                 }
     36             }
     37         }
     38     }
     39     printf("\n\nCount: %d\n", count);
     40     return 0;
     41 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror