Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

Area Of the triangle with condition

// C# program to print
// Floyd's triangle
using System;
 
class Test {
     
    // Function to find area
    static float findArea(float a, float b,
                        float c)
    {
         
        // Length of sides must be positive
        // and sum of any two sides
        // must be smaller than third side.
        if (a < 0 || b < 0 || c <0 ||
        (a + b <= c) || a + c <=b ||
            b + c <=a)
        {
            Console.Write("Not a valid triangle");
            System.Environment.Exit(0);
        }
        float s = (a + b + c) / 2;
        return (float)Math.Sqrt(s * (s - a) *
                            (s - b) * (s - c));
    }
         
    // Driver code
    public static void Main()
    {
        float a = 3.0f;
        float b = 4.0f;
        float c = 5.0f;
     
        Console.Write("Area is " + findArea(a, b, c));
    }
}
 
// This code is contributed Nitin Mittal.
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Area #Of #triangle #condition
ADD COMMENT
Topic
Name
3+7 =