C Source Code/Area of a triangle
< C Source Code#include<stdio.h> #include<math.h> /* main: calculate the area of a triangle using Heron's Formula */ int main(void) { float a, b, c, s, area; printf("Enter sides of triangle: "); scanf("%f%f%f", &a, &b, &c); s = (a + b + c) / 2; /* no error checking: sqrt() works only if its arg >= 0 */ area = sqrt(s * (s-a) * (s-b) * (s-c)); printf("Area = %f\n", area); /* indicate success */ return 0; }
This article is issued from Wikiversity - version of the Wednesday, January 01, 2014. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.