Write a program in C# Sharp to find the sum of the series [ x - x^3 + x^5 + ......] using for loop. I did till here...but not getting the ouput.
int x = int.Parse(Console.ReadLine());
int n = int.Parse(Console.ReadLine());
double sum = 0;
for (int i = 1; i <= n; i=i+2)
{
double result = Math.Pow(x, i);
sum = sum + result;
}
Console.WriteLine(sum);
Laxmidhar SahooPosted Dec 19, 2017, 4:49 AM
Rajeesh MenothPosted Dec 18, 2017, 3:50 AM
harish reddyPosted Dec 18, 2017, 3:48 AM
Rajeesh MenothPosted Dec 18, 2017, 3:35 AM
Ramesh PalanivelPosted Dec 18, 2017, 3:34 AM