What is wrong with this program?
What is wrong with this program?
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
So i do this and here is my program to find a,b and c.
Code:
#include <stdio.h>
main()
{
int a,b,c;
for (a=0;a<=1000;a++)
{
for (b=0;b<=1000;b++)
{
for (c=0;c<=1000;c++)
{
if (a+b==c&&((a*a)+(b*b)==(c*c))&&(a<b<c))
printf("%d,%d,%d",a,b,c);
}
}
}
getch();
}