C-Program to find THE SUM OF SERIES [ 1-X^2/2!+X^4/4!- ………]

/* PROGRAM THE SUM OF SERIES [ 1-X^2/2!+X^4/4!- .........] */
#include<stdio.h>
#include<conio.h>
void main()
{
	float x, sum, term, denr;
	int i, n;
	printf("enter the Value of x and (n) Number of terms to be sum\t :");
	scanf("%f%d", &x, &n);
	sum = 1; term = 1;
	for (i = 1; i<n; i++)
	{
		denr = (2 * i)*(2 * i - 1);
		term = -term*x*x / denr;
		sum = sum + term;
	}
	printf("\nthe sum = %f\nNumber of terms = %d\nvalue of x = %f\n", sum, n, x);
	getch();
}

Capture.PNG
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s