logo image

C# program to calculate triangle circumference


Following program shows you how to calculate triangle circumference. This program gets triangle sides from user and calculates circumference and prints it using following formula Circumference = side1 + side2 + side3

using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine("Enter the side1 of triangle:");
    double triangleSide1 = Convert.ToDouble(Console.ReadLine());
    Console.WriteLine("Enter the side2 of triangle:");
    double triangleSide2 = Convert.ToDouble(Console.ReadLine());
    Console.WriteLine("Enter the side3 of triangle:");
    double triangleSide3 = Convert.ToDouble(Console.ReadLine());
    double circumferenceOfTriangle = triangleSide1 + triangleSide2 + triangleSide3;
    Console.WriteLine("Circumference of triangle is: " + circumferenceOfTriangle);



Enter the side1 of triangle:
Enter the side2 of triangle:
Enter the side3 of triangle:
Circumference of triangle is: 45