3 4 5 makes a right-angled triangle 3 5 4 makes a right-angl
3 4 5 makes a right-angled triangle 3 5 4 makes a right-angled triangle 5 4 3 makes a right-angled triangle 4 5 6 makes a right-angled triangle aright-angled triangle is such that when the? length , base and the hypotenuse can satisfy the equation c2=a2+b2 , where integer numbers , find out the they make a right-angled triangle .
VulpesPosted Sep 25, 2013, 5:56 AM
When you've finished, enter -1 for either the length, base or hypotenuse.
There's a list of Pythagorean triples (as they're called) here:
http://en.wikipedia.org/wiki/Pythagorean_triple
nazim mahiedPosted Sep 25, 2013, 5:52 AM
VulpesPosted Sep 25, 2013, 5:07 AM
using System;
class Program
{
static void Main()
{
Console.WriteLine("Enter data for triangle or -1 to quit\n");
while(true)
{
Console.Write("Length : ");
int l = int.Parse(Console.ReadLine());
if (l == -1) return;
Console.Write("Base : ");
int b = int.Parse(Console.ReadLine());
if (b == -1) return;
Console.Write("Hypotenuse : ");
int h = int.Parse(Console.ReadLine());
if (h == -1) return;
bool result = IsRightAngledTriangle(l, b, h);
if (result)
{
Console.WriteLine("It's a right angled triangle");
}
else
{
Console.WriteLine("It's not a right angled triangle");
}
Console.WriteLine();
}
}
static bool IsRightAngledTriangle(int l, int b, int h)
{
return h * h == l * l + b * b;
}
}