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);

Rajeesh MenothRank #118 · 18.4K reputationPosted Dec 17, 2017, 10:35 PM EST
Ramesh PalanivelRank #372 · 6.8K reputationPosted Dec 17, 2017, 10:34 PM EST
harish reddy176 reputationPosted Dec 17, 2017, 10:48 PM EST
Rajeesh MenothRank #118 · 18.4K reputationPosted Dec 17, 2017, 10:50 PM EST
Laxmidhar SahooRank #383 · 6.6K reputationPosted Dec 18, 2017, 11:49 PM EST