Input three numbers, write a program to prove that this three numbers are Pythagorean triples.
N.B. a2 = b2 +c2
#include <stdio.h>
#include <conio.h>
void main ( )
{
int a,b,c;
clrscr ( );
printf ("\n Enter three numbers..:"); scanf ("%d%d%d",&a,&b,&c);
if ( a * a == b * b + c * c )
{
printf ("\n Three numbers are pythagorean tripples.");
}
else if ( b * b == a * a + c *c )
{
printf ("\n Three numbers are pythagorean tripples.");
}
else if ( c * c == b * b + a * a )
{
printf ("\n Three numbers are pythagorean tripples.");
}
else
{
printf ("\n Three numbers are not pythagorean tripples.");
}
getch();
}
Some solved problem in C language
ReplyDelete