Views: 140
Following program shows you how to calculate triangle area.
This program gets triangle base and height from user and calculates area and prints it using following formulaArea = base X height / 2
#include <stdio.h>
int main() {
float triangleBase;
float triangleHeight;
printf("Enter the base of triangle:");
scanf("%f", &triangleBase);
printf("Enter the height of triangle:");
scanf("%f", &triangleHeight);
float areaOfTriangle = (triangleBase * triangleHeight) / 2;
printf("Area of triangle is: %f", areaOfTriangle);
}
Output:
Enter the base of triangle: 45
Enter the height of triangle: 20
Area of triangle is: 450.000000
On By
Navya
Top Tutorials
492.5K
32K
21.8K
18.7K
18.7K
6.7K
6.7K
4.9K
3.3K
3.2K
Top Questions
18.7K
14.5K
8.3K
6.6K
6.2K
5.7K
4.8K
4.8K
4.3K
3.9K
Top Articles
1.9K
1.6K
947
Top Blogs
796
779
55
Top News
754
686
670
398
385
385