Write a C# Sharp program to find the sum of the interior angles (in degrees) of a given Polygon. Input number of straight line(s)

  • برمجة سي شارب
  • برمجة

Write a C# Sharp program to find the sum of the interior angles (in degrees) of a given Polygon. Input number of straight line(s)

From Wikipedia,
In geometry, a polygon is a plane figure that is described by a finite number of straight line segments connected to form a closed polygonal chain or polygonal circuit. The solid plane region, the bounding circuit, or the two together, may be called a Polygon.

Sample Output:

Input number of straight lines of the polygon:
Sum of the interior angles (in degrees) of the said polygon: -360

الأجوبة

using System;
namespace exercises
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Input number of straight lines of the polygon:");
            int n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Sum of the interior angles (in degrees) of the said polygon: " + test(n));            
        }
        public static int test(int num)
        {
            return 180 * (num - 2);
        }
    }
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...