FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 20   



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 formula
Area = base X height / 2

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine("Enter the base of triangle:");
    double triangleBase = Convert.ToDouble(Console.ReadLine());
    Console.WriteLine("Enter the height of triangle:");
    double triangleHeight = Convert.ToDouble(Console.ReadLine());
    double areaOfTriangle = (triangleBase * triangleHeight) / 2;
    Console.WriteLine("Area of triangle is: " + areaOfTriangle );

  }
}

Output:

Enter the base of triangle:
 22
Enter the height of triangle:
 25
Area of triangle is: 275



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News