Right Triangle Checker

Write a program to allow the user to enter three integers. You must use do-while or while loops to enforce that these integers are in ascending order, though duplicate numbers are allowed.

Tell the user whether or not these integers would represent the sides of a right triangle.

Enter three integers:
Side 1: 4
Side 2: 3
3 is smaller than 4.  Try again.
Side 2: -9
-9 is smaller than 4.  Try again.
Side 2: 5
Side 3: 1
1 is smaller than 5.  Try again.
Side 3: 5

Your three sides are 4 5 5
NO!  These sides do not make a right triangle!

 

Enter three integers:
Side 1: 6
Side 2: 8
Side 3: 10

Your three sides are 6 8 10
These sides *do* make a right triangle.  Yippy-skippy!



©2013 Graham Mitchell

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Creative Commons License