fork(1) download
  1. // C code
  2. // This program will calculate the Perimeter of a right triangle.
  3. // Developer: Professor Grady CMIS102
  4. // Date: Feb. 13, 2017
  5.  
  6. #include <stdio.h>
  7.  
  8.  
  9. int main ()
  10. {
  11. /* variable definitions: */
  12. float base, height, area, step1, step2;
  13.  
  14.  
  15. /* Prompt user for base */
  16. printf("Enter the base of the triangle: \n");
  17.  
  18. // Input the base
  19. scanf("%f", &base);
  20.  
  21. /* Prompt user for height */
  22. printf("Enter the height of the triangle: \n");
  23.  
  24. // Input the base
  25. scanf("%f", &height);
  26.  
  27. // Calculate Perimeter
  28.  
  29. step1 = (base * base) + (height * height);
  30.  
  31. step2 = sqrt(step1); // Utilize C square root function
  32.  
  33. area = base + height + step2;
  34.  
  35. // Print Perimeter
  36. printf("Perimeter is : %f\n", &area);
  37.  
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0s 4544KB
stdin
2.0 2.0 2.0
stdout
Enter the base of the triangle: 
Enter the height of the triangle: 
Perimeter is : 0.000000