fork download
  1. // C code
  2. // This program will calculate the area of a right triangle.
  3. // Developer: Faculty CMIS102
  4. // Date: June 23, 2018
  5. #include <stdio.h>
  6. int main ()
  7. {
  8. /* variable definition: */
  9. float base, height, area;
  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 height
  17. scanf("%f", &height);
  18. // Calculate the Area
  19. area= 0.5 * (base * height);
  20. // Print the result
  21. printf("Area is : %f\n", area);
  22. return 0;
  23. }
Success #stdin #stdout 0s 4544KB
stdin
2.67
3.23
stdout
Enter the base of the triangle: 
Enter the height of the triangle: 
Area is : 4.312050