Skip to content

Triangle area (Heron)

C# Heron's formula

Flowchart (ISO 5807)

StartInput a, b, cs = (a + b + c) / 2area = √(s(s − a)·(s − b)·(s − c))Return areaEndFigure 1 — Program.HeronArea

Source code

C#
class Program {
    static double HeronArea(double a, double b, double c) {
        double s = (a + b + c) / 2;
        double area = System.Math.Sqrt(s * (s - a) * (s - b) * (s - c));
        return area;
    }
}

The editor opens with this code — change it and the chart redraws.

Language
C#
Constructs
Heron's formula
Topic
Input/Output
Formats
Word, Visio, draw.io, PDF, SVG

Related examples