fork download
  1. // C code
  2. // This program will calculate the area of a right triangle.
  3. // Developer: Faculty CMIS102
  4. // Date: Jan 31, XXXX
  5. #include <stdio.h>
  6. #include <math.h>
  7. int main ()
  8. {
  9. /* variable definition: */
  10. int base, height, perimeter;
  11. /* Prompt user for base */
  12. printf("Enter the base of the triangle: \n");
  13. // Input the base
  14. scanf("%d", &base);
  15. /* Prompt user for height */
  16. printf("Enter the height of the triangle: \n");
  17. // Input the base
  18. scanf("%d", &height);
  19. // Calculate the Perimeter
  20. perimeter = base + height + sqrt(base * base + height * height);
  21. // Print the result
  22. printf("Perimeter is : %d\n", perimeter);
  23. return 0;
  24. }
Success #stdin #stdout 0s 9432KB
stdin
5
6
stdout
Enter the base of the triangle: 
Enter the height of the triangle: 
Perimeter is : 18