This C# Program Finds the Value of sin(x) from the series sin(x)=x-x^3/3!+x^5/5-x^7/7!

Here is source code of the C# program to Find the Value of sin(x) from the Series. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

`/*`

`* C# Program to calculate the series sin(x)=x-x^3/3!+x^5/!-x^7/7!+......`

`*/`

using System;

`class sine`

`{`

int deg, n;

public void readdata()

`{`

Console.WriteLine("Enter the Number of Terms:");

n = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter the Angle in Degrees:");

deg = Convert.ToInt32(Console.ReadLine());

`}`

public void sineseries()

`{`

float x, s = 0.0f, t;

x = (float)Math.PI * deg / 180f;

s = x;

t = x;

for (int i = 1; i <= n; i++)

`{`

t = (-t * x * x) / ((2 * i) * (2 * i + 1));

s = s + t;

`}`

Console.WriteLine("Sin({0})={1}", deg, s);

`}`

public static void Main()

`{`

sine s = new sine();

s.readdata();

s.sineseries();

`}`

`}`

Here is the output of the C# Program:

Enter the Number of Terms: 20 Enter the Angle in Degrees: 90 Sin(90)=0.99999994

**Sanfoundry Global Education & Learning Series – 1000 C# Programs.**

If you wish to look at all C# Programming examples, go to 1000 C# Programs.