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. float base, height, area;
  11. /* Prompt user for base */
  12. printf("Enter the base of the triangle: \n");
  13. // Input the base
  14. scanf("%f", &base);
  15. /* Prompt user for height */
  16. printf("Enter the height of the triangle: \n");
  17. // Input the base
  18. scanf("%f", &height);
  19. // Calculate the Area
  20. area= 0.5 * (base * height);
  21. // Print the result
  22. printf("Area is : %f\n", area);
  23. return 0;
  24. }
Success #stdin #stdout 0s 9432KB
stdin
100.0
400.0
stdout
Enter the base of the triangle: 
Enter the height of the triangle: 
Area is : 20000.000000