C Online Compiler
Example: C program to find the area of a triangle if base and height are given
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C program to find the area of a triangle if base and height are given #include <stdio.h> int main() { float b, h, a; // b = base // h = height // a = area printf("Enter the base & height of the triangle::\n"); scanf("%f%f", &b, &h); // Calculate area of the triangle a = (float)((b * h) / 2); // Output printf("\nArea of the triangle = %f sq. units", a); return 0; }
5 7
Output
Clear
ADVERTISEMENTS