Write a C# Sharp program to find the value of PI up to n (given number) decimals places
- برمجة سي شارب
- برمجة
- 2021-05-31
- ahmadghneem
الأجوبة
using System;
using System.Linq;
namespace exercises
{
class Program
{
static void Main(string[] args)
{
int n = 2;
Console.WriteLine("Value of PI up to "+ n + " decimals places -> " + test(n));
n = 7;
Console.WriteLine("\nValue of PI up to " + n + " decimals places -> " + test(n));
n = 15;
Console.WriteLine("\nValue of PI up to " + n + " decimals places -> " + test(n));
}
public static decimal test(int n)
{
return decimal.Round(3.1415926535897931m, n);
}
}
}أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال