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