/* This program demonstrates redundant code that should
   be placed into a function.
*/ 
#include <stdio.h>
#include <math.h>

int main()
{
   int lengthOfA; /* Length of one of the known sides */
   int lengthOfB; /* Length of the other known side   */
   int sumOfSquares; /* Sum of the squares of the known side */
   double hypotenuse;   /* Length of the hypotenuse */
   
   sumOfSquares = 5 * 5 + 9 * 9;
   hypotenuse = sqrt(sumOfSquares);
   printf("The hypotenuse of a triangle with sides %d and %d is %.1f\n", 5, 9, hypotenuse);
   
   
   sumOfSquares = 3 * 3 + 8 * 8;
   hypotenuse = sqrt(sumOfSquares);
   printf("The hypotenuse of a triangle with sides %d and %d is %.1f\n", 3, 8, hypotenuse);

   /* Read the input data */
   printf ("Enter the lengths of the two sides: ");
   scanf ("%d %d",&lengthOfA, &lengthOfB);
   
   /* Compute sum of squares */
   sumOfSquares = lengthOfA * lengthOfA +  lengthOfB * lengthOfB;
   
   /* Find length of hypotenuse */
   hypotenuse = sqrt(sumOfSquares);
   
   /* Print the length of hypotenuse */
   printf("The hypotenuse of a triangle with sides %d and %d is %.1f\n", 
         lengthOfA, lengthOfB, hypotenuse);
   
   return (0);
}