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