Computer Science, asked by helpfulgirl2021, 3 days ago

Write a program in C++ to input three numbers and check whether they are Pythagorean triplet or not.​
[A Pythagorean triplet is a set of 3 number that satisfy the equation a2 + b2= c2 ]

Answers

Answered by bhargavi30062007
0

Answer:

/* Determine and print Pythagorean triplets */

#include<stdio.h>

#include<conio.h>

#include<math.h>

void main() {

int max; /* max value of side a or b */

int a, b; /* two sides of a triangle */

printf("Enter max value of sides a, b: ");

scanf("%d", &max);

for (a = 1; a <= max; a++) {

for (b = a; b <= max; b++) {

float c = sqrt(a *a+ b * b); /*third side*/

if (c == (int) c)

printf ("%2d %2d %2d\n", a, b, (int) c);

}

}

getch();

}

Similar questions