Formula #6 (Area of triangle)
Enter length of base: 5
Enter height: 10
Area of triangle: 25
The program for the formula is written
in C# programming language and will accept a number as length and height. Based
on the formula it will find out the area of triangle.
Let’s find out a simple and easy way
to code these formula.
Practical Implementation:
using System;
namespace patternProblem.Formula
{
class Formula6 //area of triangle
{
static void Main(string[] args)
{
Console.Write("Enter length of base: ");
double baseLength = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter height: ");
double height = Convert.ToDouble(Console.ReadLine());
double area = 0.0;
area = ((baseLength * height) / 2);
Console.WriteLine("Area of triangle: {0}", area);
Console.ReadKey();
}
}
}
Output:
The input
length here is 5 and height is 10. So, based on the area of triangle formula.
The output is shown below:
Enter length of base: 5
Enter height: 10
Area of triangle: 25
Press any key to continue . . .
For any
query, comment us below.
Skip to
Main Table – Formula
based program
Keep learning and sharing...
No comments:
Post a Comment